473,398 Members | 2,393 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

parameter problems

i have info table in sql server 2000

INFO:

name surname
______________________________________
1 Null

select * from INFO where name=@name and surname=@surname
i run this and input
name=1
surname=

but then no results turn back empty why???????
Sep 26 '05 #1
7 1173
because NULL is a value and your input is empty string!!!!

Ahmad

"bafidi" <ba****@discussions.microsoft.com> wrote in message
news:57**********************************@microsof t.com...
i have info table in sql server 2000

INFO:

name surname
______________________________________
1 Null

select * from INFO where name=@name and surname=@surname
i run this and input
name=1
surname=

but then no results turn back empty why???????

Sep 26 '05 #2
how can i input null value to a parameter

"msnews" wrote:
because NULL is a value and your input is empty string!!!!

Ahmad

"bafidi" <ba****@discussions.microsoft.com> wrote in message
news:57**********************************@microsof t.com...
i have info table in sql server 2000

INFO:

name surname
______________________________________
1 Null

select * from INFO where name=@name and surname=@surname
i run this and input
name=1
surname=

but then no results turn back empty why???????


Sep 26 '05 #3
Hi Bafidi,

Use DBNull.Value for a null.

On Mon, 26 Sep 2005 14:56:02 +0200, bafidi <ba****@discussions.microsoft.com> wrote:
how can i input null value to a parameter

"msnews" wrote:
because NULL is a value and your input is empty string!!!!

Ahmad

"bafidi" <ba****@discussions.microsoft.com> wrote in message
news:57**********************************@microsof t.com...
> i have info table in sql server 2000
>
> INFO:
>
> name surname
> ______________________________________
> 1 Null
>
> select * from INFO where name=@name and surname=@surname
>
>
> i run this and input
> name=1
> surname=
>
> but then no results turn back empty why???????



--
Happy coding!
Morten Wennevik [C# MVP]
Sep 26 '05 #4
how can i write null value?

for example:
dim count1 as integer
count1=DBNull.Value


"Morten Wennevik" wrote:
Hi Bafidi,

Use DBNull.Value for a null.

On Mon, 26 Sep 2005 14:56:02 +0200, bafidi <ba****@discussions.microsoft.com> wrote:
how can i input null value to a parameter

"msnews" wrote:
because NULL is a value and your input is empty string!!!!

Ahmad

"bafidi" <ba****@discussions.microsoft.com> wrote in message
news:57**********************************@microsof t.com...
> i have info table in sql server 2000
>
> INFO:
>
> name surname
> ______________________________________
> 1 Null
>
> select * from INFO where name=@name and surname=@surname
>
>
> i run this and input
> name=1
> surname=
>
> but then no results turn back empty why???????


--
Happy coding!
Morten Wennevik [C# MVP]

Sep 27 '05 #5
bafidi <ba****@discussions.microsoft.com> wrote:
how can i input null value to a parameter


It doesn't matter even if you do - your query still won't work, because
in SQL, null doesn't equal itself. You need something like

select * from INFO where name=@name and (surname=@surname OR
(surname is null and @surname is null))

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Sep 27 '05 #6
You need to use SqlParameter/OleDbParameter

[C#]
SqlParameter param1 = new SqlParameter("@count1", SqlDbType.Int);
param1.Value = DBNull.Value;
On Tue, 27 Sep 2005 07:44:01 +0200, bafidi <ba****@discussions.microsoft.com> wrote:
how can i write null value?

for example:
dim count1 as integer
count1=DBNull.Value


"Morten Wennevik" wrote:
Hi Bafidi,

Use DBNull.Value for a null.

On Mon, 26 Sep 2005 14:56:02 +0200, bafidi <ba****@discussions.microsoft.com> wrote:
> how can i input null value to a parameter
>
> "msnews" wrote:
>
>> because NULL is a value and your input is empty string!!!!
>>
>> Ahmad
>>
>>
>>
>> "bafidi" <ba****@discussions.microsoft.com> wrote in message
>> news:57**********************************@microsof t.com...
>> > i have info table in sql server 2000
>> >
>> > INFO:
>> >
>> > name surname
>> > ______________________________________
>> > 1 Null
>> >
>> > select * from INFO where name=@name and surname=@surname
>> >
>> >
>> > i run this and input
>> > name=1
>> > surname=
>> >
>> > but then no results turn back empty why???????
>>
>>
>>
>


--
Happy coding!
Morten Wennevik [C# MVP]


--
Happy coding!
Morten Wennevik [C# MVP]
Sep 27 '05 #7
> select * from INFO where name=@name and (surname=@surname OR
(surname is null and @surname is null))


Terrible that SQL in another language (where I don't like the used operands)
it would in my opinion simple be

if (name==@name){if (surname==@surname){do what you need to do;}}

:-)

Cor
Sep 27 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: | last post by:
From ASP I run a query using MIN(some_field/parameter) Now I need to pass this parameter to the query from ASP code How do I do that? Syntax like MIN( / ) does not work
3
by: cassandra.flowers | last post by:
Hi, I was wondering if it is possible (Using access) to have a query parameter as a drop down box rather than a text box? e.g. typing as criteria for a query produces a box with a text box...
6
by: Andy | last post by:
Hello, I am having many problems with setting up a parameter query that searches by the criteria entered or returns all records if nothing is entered. I have designed an unbound form with 3...
1
by: Trevor Morgan | last post by:
I've been having problems when a templated member function has the same name as ANY previously defined template parameter. Here's the simplest case that demonstrates the problem. This fails to...
0
by: silesius | last post by:
I've been using VS.NET 2003 to develop a webapplication using C#. Today I exported the application to another webserver I begun experiencing problems. It's a simple application that retrieves...
7
by: Richard Grant | last post by:
Hi. In c/C++ i can pass the address of a subroutine to another subroutine as an actual parameter How do I do that in VB .NET What should be the syntax for a parameter to receive the address of a...
4
by: Ranginald | last post by:
Hi, I'm having trouble passing a parameter from my default.aspx page to my default2.aspx page. I have values from a query in a list box and the goal is to pass the "catID" from default.aspx...
0
by: Billie Boy | last post by:
Hi to all. I’m new here and am coming to you from Melbourne Australia. So a big HELLO 2 ALL. Now I am encountering an annoying problem in the SQL builder of the copy of VB.6 that I am using at...
4
by: Martin Evans | last post by:
Hi, I'm getting: DBD::DB2::db do failed: SQL0440N No authorized routine named "CONCAT" of type "FUNCTION" having compatible arguments was found. SQLSTATE=42884 for some SQL like this:
16
by: hzmonte | last post by:
Correct me if I am wrong, declaring formal parameters of functions as const, if they should not be/is not changed, has 2 benefits; 1. It tells the program that calls this function that the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.