PC Review


Reply
Thread Tools Rate Thread

Checking for DBNull

 
 
John
Guest
Posts: n/a
 
      10th Jan 2008
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


 
Reply With Quote
 
 
 
 
Claes Bergefall
Guest
Posts: n/a
 
      10th Jan 2008
If objResultClient.IsDBNull(2) Then
// Do your stuff here
End If

/claes

"John" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>



 
Reply With Quote
 
Phill W.
Guest
Posts: n/a
 
      10th Jan 2008
John wrote:

> How can I check objResultClient.GetValue(2) = System.DBNull for dbnull
> value?


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

HTH,
Phill W.
 
Reply With Quote
 
Herfried K. Wagner [MVP]
Guest
Posts: n/a
 
      11th Jan 2008
"John" <(E-Mail Removed)> schrieb:
> 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...'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Checking for DBNull with generics Leon Mayne Microsoft Dot NET 6 31st Mar 2008 03:55 PM
Checking for DBNull John Microsoft VB .NET 3 11th Jan 2008 01:33 AM
Checking for DBNull Sreppohcdoow Microsoft ADO .NET 2 19th Apr 2006 03:39 AM
Checking for boolean DBNull G Dean Blake Microsoft ASP .NET 1 20th Mar 2005 01:17 AM
Conflicting used space information when checking the drive property against marking all files and checking the marked file properties. elloko Windows XP Configuration 3 19th Dec 2004 05:34 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:16 PM.