This is a migrated thread and some comments may be shown as answers.

How to use session variable to retrive row that contain null value

0 Answers 63 Views
Grid
This is a migrated thread and some comments may be shown as answers.
LamKhoa
Top achievements
Rank 1
LamKhoa asked on 26 Jul 2011, 05:24 PM
Hi All,
I have a simple problem that has made me pondering for days on Google and still have no answer:
For example, I have following SQL query:

SELECT 
    ID, AccountNum, Name 
FROM
    Table1
WHERE
     AccountNum = @AccountNum
     Name = @Name

(In which @AccountNum and @Name are session variable).

Then in the C# code behind. I wrote:
Session["AccountNum"] = DBNull.Value;
Session["Name"] = DBNull.Value;

Logically, It would return for me a list of row in which both AccountNum and Name are NULL value. However, it didn't work. It's only work if both Name and AccountNum are varchar datatype in database (But in this case, AccountNum is a Int32 datatype).

Please let me know if any of you know any work around.

Thanks All

Lamk.

No answers yet. Maybe you can help?

Tags
Grid
Asked by
LamKhoa
Top achievements
Rank 1
Share this question
or