Checking for DBNull

  • Thread starter Thread starter John
  • Start date Start date
J

John

Hi

I am using a oledb reader to read from a table. The problem is that system
generates an exception when MyReader.GetValue(2) returns a value of type
system.dbnull. The system does not allow me to test this expression for
system.dbnull as below;

If objResultClient.GetValue(2) Is System.DBNull Then

How can I check objResultClient.GetValue(2) = System.DBNull for dbnull
value? I have tried objResultClient.GetValue(2) Is Nothing as well but that
does not catch system.dbnull values either.

Thanks

Regards
 
John said:
How can I check objResultClient.GetValue(2) = System.DBNull for dbnull
value?

If objResultClient.GetValue(2) Is System.DBNull.Value Then
. . .

HTH,
Phill W.
 
John said:
I am using a oledb reader to read from a table. The problem is that system
generates an exception when MyReader.GetValue(2) returns a value of type
system.dbnull. The system does not allow me to test this expression for
system.dbnull as below;

If objResultClient.GetValue(2) Is System.DBNull Then

'If ... Is DBNull.Value Then...' or 'If IsDBNull(...) Then...'.
 
Back
Top