null character evaluation ?

  • Thread starter Thread starter Steve Caliendo
  • Start date Start date
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);
...
}
 
If Rs1.Item(0) = DBNull Then

I get the error that:



It is a type and cannot be used as an expression.
 
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.
 
Back
Top