TypeOf vs IsDBNull

  • Thread starter Thread starter Anonymous
  • Start date Start date
A

Anonymous

Which of the following codes is recommended?
Is there any difference between them?


If TypeOf dr("colname") Is DBNull Then
' Do work
End If


If IsDBNull(dr("colname")) Then
' Do work
EndIf
 
....or:

If "colname" = DBNull.value Then
' Do work
End If

They will all work, but since you are checking for a null value, using
DBNull.value or IsDBNull I think is more direct.
 
I use the DataRow.IsNull method:

If dr.IsNull("colname") Then
' column is null
Endif

TP
 
Back
Top