problem with null data in sql

Discussion in 'ASP .Net' started by luna, Jan 28, 2004.

  1. luna

    luna Guest

    could someone explain the meaning behind :- System.IndexOutOfRangeException:
    firstname1

    when the code is :-

    If objDR("firstname1") Is System.DBNull.Value Then
    firstname1.Text = ""
    Else : firstname1.Text = objDR("fname1")
    End If


    and theres no entry in the database if theres an entry in the database there
    isnt a problem
     
    luna, Jan 28, 2004
    #1
    1. Advertising

  2. luna

    Janaka Guest

    luna,

    I take it objDR is a DataReader? Try using its method of
    objDR.IsDBNull() - you'll have to use the ordinal number of "firstname1"
    instead.
    So your code will look more like:

    If objDR.IsDBNull(0) Then
    ....
    End If

    "luna" <> wrote in message
    news:ApNRb.169$...
    > could someone explain the meaning behind :-

    System.IndexOutOfRangeException:
    > firstname1
    >
    > when the code is :-
    >
    > If objDR("firstname1") Is System.DBNull.Value Then
    > firstname1.Text = ""
    > Else : firstname1.Text = objDR("fname1")
    > End If
    >
    >
    > and theres no entry in the database if theres an entry in the database

    there
    > isnt a problem
    >
    >
     
    Janaka, Jan 28, 2004
    #2
    1. Advertising

  3. luna

    Dan Brussee Guest

    Your comment that there is no entry in the database makes me think
    that the objDR is empty, so there is no current record. This is very
    different than a field having a null value. Check if objDR is nothing
    (or null depending on language flavor) before testing. You should
    probably handle a null record differently than a null field value.

    On Wed, 28 Jan 2004 11:54:51 -0000, "luna" <> wrote:

    >could someone explain the meaning behind :- System.IndexOutOfRangeException:
    >firstname1
    >
    >when the code is :-
    >
    >If objDR("firstname1") Is System.DBNull.Value Then
    >firstname1.Text = ""
    >Else : firstname1.Text = objDR("fname1")
    >End If
    >
    >
    >and theres no entry in the database if theres an entry in the database there
    >isnt a problem
    >
     
    Dan Brussee, Jan 28, 2004
    #3
  4. luna

    luna Guest

    that did the trick thanks!!

    mark


    "Janaka" <> wrote in message
    news:...
    > luna,
    >
    > I take it objDR is a DataReader? Try using its method of
    > objDR.IsDBNull() - you'll have to use the ordinal number of "firstname1"
    > instead.
    > So your code will look more like:
    >
    > If objDR.IsDBNull(0) Then
    > ...
    > End If
    >
    > "luna" <> wrote in message
    > news:ApNRb.169$...
    > > could someone explain the meaning behind :-

    > System.IndexOutOfRangeException:
    > > firstname1
    > >
    > > when the code is :-
    > >
    > > If objDR("firstname1") Is System.DBNull.Value Then
    > > firstname1.Text = ""
    > > Else : firstname1.Text = objDR("fname1")
    > > End If
    > >
    > >
    > > and theres no entry in the database if theres an entry in the database

    > there
    > > isnt a problem
    > >
    > >

    >
    >
     
    luna, Jan 28, 2004
    #4
  5. luna

    luna Guest

    yes no entry in the database

    If objDR.IsDBNull(1) Then
    seems to do the trick

    thanks

    mark

    "Dan Brussee" <> wrote in message
    news:eek:...
    > Your comment that there is no entry in the database makes me think
    > that the objDR is empty, so there is no current record. This is very
    > different than a field having a null value. Check if objDR is nothing
    > (or null depending on language flavor) before testing. You should
    > probably handle a null record differently than a null field value.
    >
    > On Wed, 28 Jan 2004 11:54:51 -0000, "luna" <> wrote:
    >
    > >could someone explain the meaning behind :-

    System.IndexOutOfRangeException:
    > >firstname1
    > >
    > >when the code is :-
    > >
    > >If objDR("firstname1") Is System.DBNull.Value Then
    > >firstname1.Text = ""
    > >Else : firstname1.Text = objDR("fname1")
    > >End If
    > >
    > >
    > >and theres no entry in the database if theres an entry in the database

    there
    > >isnt a problem
    > >

    >
     
    luna, Jan 28, 2004
    #5
    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. Kivak Wolf
    Replies:
    2
    Views:
    10,077
    Kivak Wolf
    Jun 28, 2005
  2. Replies:
    5
    Views:
    26,704
    Mike Schilling
    Mar 29, 2006
  3. Harry Zoroc
    Replies:
    1
    Views:
    948
    Gregory Vaughan
    Jul 12, 2004
  4. thersitz
    Replies:
    3
    Views:
    646
    thersitz
    Jan 31, 2007
  5. ecoolone
    Replies:
    0
    Views:
    766
    ecoolone
    Jan 3, 2008
Loading...

Share This Page