null character evaluation ?

M

Mickey Williams

Are you testing for a character with a scalar value of zero, or a null value
in a database column? If you want to test the value of characters, use the
string.Chars property. If you want to test if a column has a null value,
check if the value has a type of DBNull. If you're using a data reader, use
the IsDBNull method:

if(reader.Read())
{
int n = reader.IsDBNull(0)? 0: reader.GetInt32(0);
...
}
 
S

Steve Caliendo

If Rs1.Item(0) = DBNull Then

I get the error that:



It is a type and cannot be used as an expression.
 
P

Peter Rilling

Sorry, DBNull is part of the SqlTypes namespace. It is an actual object in
the framework.

Althought I have not compiled this, try
If Rs1.Item(0) = System.Data.SqlTypes.DBNull Then ' Or whatever the
VB syntax might be.
 

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

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top