ladarling is correct. You want to compare to DBNull, not null.
The syntax I would use is this, as you loop through the results of the SqlDataReader returned by a call to ExecuteReader():
if (!reader.IsDBNull(reader.G
{
}
Some of that is my personal preference, but DBNull is definitely what you are trying to compare to.
Main Topics
Browse All Topics





by: ladarlingPosted on 2009-08-31 at 10:20:57ID: 25224548
dr[Sendate]!=DBnull.Value
From MSDN:
Do not confuse the notion of nullNothingnullptra null reference (Nothing in Visual Basic) in an object-oriented programming language with a DBNull object. In an object-oriented programming language, nullNothingnullptra null reference (Nothing in Visual Basic) means the absence of a reference to an object. DBNull represents an uninitialized variant or nonexistent database column.
http://msdn.microsoft.com/ en-us/libr ary/system .dbnull.as px