Database null value problem

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

Guest

this is my database query in my application

string strSQL = "select AB_CD from MY_TABLE where AB_FIELD1_NAME ='NULL' and AB_FIELD2_NAME = '" + xyz + "' "
string strKey = object.ExecuteScalar(strSQL).ToString()

here AB_CD is a primary key that i want to get from the above query, iam getting a exception here if i execute this query

the database record row will be like thi
AB_CD AB_FIELD1_NAME AB_FIELD2_NAM
124 NULL xyz
how to reference null value in a database query? is it because the way i gave the exception is occurin
 
Assuming you are using SQL Server, you can search the BookOnline for "IS
NULL"Eg:SELECT title_id, type, advance
FROM pubs.dbo.titles
WHERE advance IS NULL
José"seash said:
this is my database query in my application.

string strSQL = "select AB_CD from MY_TABLE where AB_FIELD1_NAME ='NULL'
and AB_FIELD2_NAME = '" + xyz + "' ";
string strKey = object.ExecuteScalar(strSQL).ToString();

here AB_CD is a primary key that i want to get from the above query, iam
getting a exception here if i execute this query.
 
Back
Top