PC Review


Reply
Thread Tools Rate Thread

Checking for a null value in a datareader

 
 
RSH
Guest
Posts: n/a
 
      13th Jul 2006
I have a situation where I am looping through a datareader's rows. An
exception is being generated when I attempt to check the value of a Boolean
field where it has a null value:\

If VarType(dtrList["ServiceCenter"]) != VariantType.Null And
dtrList["ServiceCenter"] = True Then

chkAssignedGroups.Items[0].Selected = True

End If

What is the correct way to do this?



Thanks,

Ron






 
Reply With Quote
 
 
 
 
Larry Lard
Guest
Posts: n/a
 
      13th Jul 2006

RSH wrote:
> I have a situation where I am looping through a datareader's rows. An
> exception is being generated when I attempt to check the value of a Boolean
> field where it has a null value:\
>
> If VarType(dtrList["ServiceCenter"]) != VariantType.Null And
> dtrList["ServiceCenter"] = True Then
>
> chkAssignedGroups.Items[0].Selected = True
>
> End If


Wow, and I thought *I* was bad at remembering what language I was using
So which is it?

--
Larry Lard
Replies to group please
When starting a new topic, please mention which version of VB/C# you
are using

 
Reply With Quote
 
sloan
Guest
Posts: n/a
 
      13th Jul 2006

if (!(dataReader.IsDBNull(0)))
{
currentOrder.CustomerID = dataReader.GetString( 0);
}


Its C#, but the property of IsDBNull (int) should be the same.







"RSH" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I have a situation where I am looping through a datareader's rows. An
> exception is being generated when I attempt to check the value of a

Boolean
> field where it has a null value:\
>
> If VarType(dtrList["ServiceCenter"]) != VariantType.Null And
> dtrList["ServiceCenter"] = True Then
>
> chkAssignedGroups.Items[0].Selected = True
>
> End If
>
> What is the correct way to do this?
>
>
>
> Thanks,
>
> Ron
>
>
>
>
>
>



 
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
Null value in Datareader axapta Microsoft VB .NET 5 30th May 2008 03:15 PM
datareader record null jack Microsoft C# .NET 3 16th Dec 2005 06:02 AM
Re: Datareader and Null Values Scott M. Microsoft ADO .NET 1 4th Aug 2004 05:56 PM
Re: SQLConnect and datareader w/NULL Anoop C M Microsoft VB .NET 0 17th Apr 2004 05:34 PM
Re: SQLConnect and datareader w/NULL Kenneth Microsoft VB .NET 0 15th Apr 2004 04:27 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:52 AM.