parameter problems

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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???????
 
bafidi said:
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))
 
You need to use SqlParameter/OleDbParameter

[C#]
SqlParameter param1 = new SqlParameter("@count1", SqlDbType.Int);
param1.Value = DBNull.Value;


how can i write null value?

for example:
dim count1 as integer
count1=DBNull.Value
 
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
 
Back
Top