Sunday, 15 September 2013

Field NULL in SQL

Field NULL in SQL

I have a table in DB:
REGULAR(num(bigint) not allow null, title(nvarchar(10)),
content(nvarchar(500)), path(nvarchar(50)) allow null)
with some data:
1.REGULAR1(1|title1|content1|path1)
2.REGULAR2(2|title2|content2|)--> path is not inputed (null)
I excute some query in SQL DB server 2008:
1. select PATH from REGULAR where num='2'; -> result is PATH:NULL
But
2. select count(*) from REGULAR where PATH = NULL; --> result is COUNT:0
(it must be 1 which has num=2)
Therefore, when I excute a queries from Webform it works wrong
string sql= select * from REGULAR;
Datatable regular= excute(sql)....
for(int i=0;i<regular.Rows.Count; i++)
{
if(regular.Rows[i]["path"]!=null)
{
Textbox1.Text= "a";//do something else...
}
else
Textbox1.Text+="b";//...
}
and the result is: Textbox.Text= "ab"---> it much be ="a". Is there any
mistake???

No comments:

Post a Comment