I have a table with a DateTime column the column can have NULL values
Now I connect to the database using an ODBC connection and get the value into a DataTable in .net / c#.
I am able to check it for NULL by going
if(String.IsNullOrEmpty(table.rows[0][0].ToString())
{
//Whatever I want to do
}
Is String.IsNullOrEmpty the correct way to check for null values.
Use DBNull.Value.Equals on the object without converting it to a string.
Here's an example:
if (! DBNull.Value.Equals(row[fieldName]))
{
//not null
}
else
{
//null
}