>If you want indicate NULL value in a datarow item, you can use like that expression:
If IsDBNull(DataRow.Item(“LATEST_DATE”)) Then
‘Write your code here
End If
If you want indicate NULL/Nothing value in a Date typed variable, you can use like that expression:
If CStr(VariableLatestDate) = “00:00″ Then
‘Write your code here
End If
The following table contains different expressions and results:
| VALUE | EXPRESSION | RESULT |
|---|---|---|
| NOT NULL | IsDBNull(DataRow.Item(“LATEST_DATE”)) | False (Boolean) |
| NOT NULL | CStr(DataRow.Item(“LATEST_DATE”)) | “1/15/2009 11:45″ (String) |
| NOT NULL | DataRow.Item(“LATEST_DATE”).ToString | “1/15/2009 11:45″ (String) |
| NULL | IsDBNull(DataRow.Item(“LATEST_DATE”)) | True(Boolean) |
| NULL | CStr(DataRow.Item(“LATEST_DATE”)) | Conversion from type ‘DBNull’ to type ‘String’ is not valid. |
| NULL | DataRow.Item(“LATEST_DATE”).ToString | “” (String) (Zero-length string) |
| Nothing (Default) | IsDBNull(VariableLatestDate) | False(Boolean) |
| Nothing (Default) | CStr(VariableLatestDate) | “00:00″ (String) |
| Nothing (Default) | VariableLatestDate.ToString | “1/1/0001 0:00″ (String) |
—
visual basic .net, vb.net, variable type, data type, 1/1/0001 , detecting null, nothing