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

Discussion in 'ASP .Net' started by rouble@gmail.com, Apr 8, 2006.

  1. Guest

    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
    , Apr 8, 2006
    #1
    1. Advertising

  2. On 8 Apr 2006 14:43:48 -0700, wrote:

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


    Lookup DBNull.
    Erik Funkenbusch, Apr 9, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    5
    Views:
    26,629
    Mike Schilling
    Mar 29, 2006
  2. Jiho Han
    Replies:
    13
    Views:
    637
    John Saunders
    Jul 29, 2006
  3. yogesh
    Replies:
    1
    Views:
    366
    Victor Bazarov
    Mar 14, 2007
  4. Hung Huynh
    Replies:
    8
    Views:
    301
    Bob Barrows
    Sep 24, 2003
  5. Replies:
    6
    Views:
    293
Loading...

Share This Page