How to I tell if a field within a recordset is NULL ?

R

rouble

Hi All,

How do I verify if a field within an ADODB.Recordset is NULL ?

I have tried the following two methods that I could think of:

1.
If Not IsNothing(rs("fieldname")) Then
something = Int32.Parse(rs("fieldname").Value())
End If

2.
If Not IsDBNull(rs("fieldname")) Then
something = Int32.Parse(rs("fieldname").Value())
End If

I keep getting the following exception, when I call Value() on any of
the returned objects:
Exception System.InvalidCastException: Cast from type 'DBNull' to type
'String' is not valid.

Any tips are much appreciated.

TIA,
rouble
 

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,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top