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 "=".

Comments

Popular posts from this blog

Working with double quotes (") in VB.Net

Using VB Script to display part of an IP address

Object reference not set to an instance of an object when using HTMLEditorExtender