dr("SomeString") = DBNull.Value > Dim s As String > If dr("SomeString") Is DBNull.Value Then > s = Nothing > Else > s = CStr(dr("SomeString")) > End If(so s cannot be DBNull.Value)
dr.IsNull("SomeInt")
I see in my code I am using it against a data row:' Based on the type Select Case lcType ' Character, memo field, NVarChar, VarChar, VarChar(MAX), NVarChar(MAX) Case "C", "M", "O", "V", "X", "Y" ' If we have a null If oRow(lcField) Is DBNull.Value Then oRow(lcField) = "" End IfI see the mentioned code for the string is not called by anything. So, that might explain the confusion.
' Return True if a date is empty ' expD1 Date Public Function EmptyDate(ByVal tdDate As Object) As Boolean Dim llEmpty As Boolean = False Dim ldDate As Date ' Based on the backend Select Case nBackend ' Visual FoxPro Case 1 ldDate = New Date(1899, 12, 30) ' If this is an empty date If tdDate = ldDate Then llEmpty = True End If ' SQL Server Case 2 ' If the date is null If tdDate Is DBNull.Value Then llEmpty = True End If ldDate = New Date(1899, 12, 30) ' If this is an empty date If tdDate = ldDate Then llEmpty = True End If ' ODBC Case 3 End Select Return llEmpty End FunctionWould you say the string explanation on null would also apply on a date? If yes, that would that make the above code obsolete?