Null Values From Database

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
 
J

Jos

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
 
R

Randy Rubin

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?
 
G

Guest

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!
 
R

Randy Rubin

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!
 
M

Mark Whitton

This example is when using a data reader and checks if a field is null

reader.IsDBNull(reader.GetOrdinal(fieldName))

Mark Whitton
 

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,755
Messages
2,569,537
Members
45,023
Latest member
websitedesig25

Latest Threads

Top