Checking for a null value in a datareader

R

RSH

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
 
L

Larry Lard

RSH said:
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?
 
S

sloan

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


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

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

Top