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...'.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top