Null Values From Database

  • Thread starter Thread starter Randy Rubin
  • Start date Start date
R

Randy Rubin

How do I handle Testing for null values in a database? Here is a Line of
Code:

If Not jNull("JNum") Is DBNull Then

And this is the Error:

BC30684: 'DBNull' is a type and cannot be used as an expression.

Thanks

Randy
 
Randy Rubin said:
How do I handle Testing for null values in a database? Here is a Line of
Code:

If Not jNull("JNum") Is DBNull Then

And this is the Error:

BC30684: 'DBNull' is a type and cannot be used as an expression.

If ( TypeOf jNull("JNum") Is DBNull ) Then

Jos
 
This:

If Not IsDBNull(jNull("JNum")) Then
Seemed to work, But now I am getting:

System.InvalidOperationException: Invalid attempt to read when no data is
present

I'm assuming this is because the value is Null... Anymore Ideas?
 
Just to give you a little bad news, none of these would work if your type of data is datetime - I am still looking for a solution for this!
 
Can someone post a code example that will check to see is the row or field
is null?

--Randy

Reza Solouki said:
Just to give you a little bad news, none of these would work if your type
of data is datetime - I am still looking for a solution for this!
 
This example is when using a data reader and checks if a field is null

reader.IsDBNull(reader.GetOrdinal(fieldName))

Mark Whitton
 
Back
Top