G
Guest
I have a column of a database that can return a Null value instead of a string.
I have a class that holds the database row, and I have tried to add a
property to handle the null but the program it blows up before it even gets
there.
For example:
given a class with a field called name with this property:
Public Property name() As String
Get
Return pvt_name
End Get
Set(ByVal name1 As String)
If name = Is DBNull.Value Then
pvt_name = space(30)
Else
pvt_name = name
End If
End Set
End Property
and a datareader column called drinst("Name")
newrec.name = drinst("Name") blows up if name is nulls. It doesn't
even get into the property statement.
Is there a way to automatically handle a null value without having to create
an IF statement for each column to check for it?
I have a class that holds the database row, and I have tried to add a
property to handle the null but the program it blows up before it even gets
there.
For example:
given a class with a field called name with this property:
Public Property name() As String
Get
Return pvt_name
End Get
Set(ByVal name1 As String)
If name = Is DBNull.Value Then
pvt_name = space(30)
Else
pvt_name = name
End If
End Set
End Property
and a datareader column called drinst("Name")
newrec.name = drinst("Name") blows up if name is nulls. It doesn't
even get into the property statement.
Is there a way to automatically handle a null value without having to create
an IF statement for each column to check for it?