Check for Null

L

Luis

Is there an easier way to check if any of the fields returned in a
select statement have null values?

After running this command:

set rs = conn.execute("select A,B,C,D,E,F,G,H,I,J from SomeTable
where...")

I could check each field this way:

If IsNull(rs("A") Then
Response.Write("The value of A is null")
Else
Response.Write("The value of A is " & rs("A"))
End If

If IsNull(rs("B") Then
Response.Write("The value of B is null")
Else
Response.Write("The value of B is " & rs("B"))
End If

If IsNull(rs("C") Then
Response.Write("The value of C is null")
Else
Response.Write("The value of C is " & rs("C"))
End If

etc.

But is there a simpler way?

Also, my "solution" probably wouldn't work if more than one recordset
was returned...
 
T

Thomas Dodds

use a null replacement in your SQL statement - I don't kow what DB you are
working with...

an oracle example: set rs = conn.execute("select NVL(A,'IsNull') AS A, ...
from SomeTable where...")
an SQL server example: set rs = conn.execute("select ISNULL(A,'IsNull') AS
A, ... from SomeTable where...")
 

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

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,278
Latest member
BuzzDefenderpro

Latest Threads

Top