Wednesday, September 07, 2005

What is System.DBNull.Value used for?

Q: What is System.DBNull.Value used for?

A: System.DBNull.Value is the value of NULL retrieved from a DB. Before assigning a database field to a variable, you should always check to see if the value returned from the DB is NOT null. Otherwise, an exception could be thrown.

Example:
If Not drPkgRec("MeetDate") Is System.DBNull.Value Then
Dim strMeetingPlace = drPkgRec("MeetPlace")
End If

Note: The Keyword "Is" is used, not "=".

No comments: