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")
>> ' 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 If >>
> ' 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 Function >>