I make a program by displaying values from a database to the user. When I query whether a field is NULL, there is an error.
My attempts:
Dim dtContacts As New DCFLEXNorthwind.ContactsDataTable
taContacts.SelectAllByID(dtContacts, ID)
Dim r As DCFLEXNorthwind.ContactsRow = dtContacts.Rows(0)
If r.Extension Is DBNull.Value Then
txtExtension.Text = ""
Else
txtExtension.Text = r.Extension
End If
If r.Extension Is DBNull Then
txtExtension.Text = ""
Else
txtExtension.Text = r.Extension
End If
If r.Extension = DBNull.Value Then
txtExtension.Text = ""
Else
txtExtension.Text = r.Extension
End If
If r.Extension = DBNull Then
txtExtension.Text = ""
Else
txtExtension.Text = r.Extension
End If
If IsDBNull(r.Extension) Then
txtExtension.Text = ""
Else
txtExtension.Text = r.Extension
End If
Then the following error occurs with the valid queries:
The value for column extension in table Contacts is DBNull.
and
Invalid conversion from type DBNull to type String.
r.Extensiondefined?