Invalid attempt to read when no data is present.

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default Invalid attempt to read when no data is present.

    Dim dr1 As SqlDataReader = MachCodeListID.GetSingleMachCode(thecodesID)

    ' Read first row from database

    dr1.Read()

    If IsDBNull(dr1("CATNUM")) Then '**************** This is where I am getting
    the error??????

    thecatnum = 0

    Else

    thecatnum = dr1("CATNUM")

    End If


    --

    ______________________
    David Fetrow
    HelixPoint LLC.
    [url]http://www.helixpoint.com[/url]
    [email]davef@helixpoint.com[/email]

    Interested in Affordable Email Marketing?
    Check out the HelixMailer at [url]http://www.helixpoint.com/helixmailer.asp[/url]
    If you are interested in becoming a Reseller of HelixPoint products, contact
    [email]davef@helixpoint.com[/email]
    ______________________


    Helixpoint Guest

  2. Similar Questions and Discussions

    1. #39014 [NEW]: php.ini data.timezone invalid
      From: deepseath at gmail dot com Operating system: Win2000 PHP version: 5.1.6 PHP Bug Type: IIS related Bug description: ...
    2. #38721 [Asn->Csd]: date_parse() invalid read
      ID: 38721 Updated by: tony2001@php.net Reported By: tony2001@php.net -Status: Assigned +Status: ...
    3. Use the DataList Control to Present and Edit Data PART 2
      Imports System Imports System.Data Imports System.Data.SqlClient Imports System.Web.UI Imports System.Web.UI.WebControls Imports...
    4. Use the DataList Control to Present and Edit Data
      I found some good information On "Use the DataList Control to Present and Edit Data" at this site...
    5. Invalid attempt to Read when reader is closed.
      hi to all, i meet some problem and didn't find any recommendation to resolve it , do you have some idia , how i can resolve this problem, a lot of...
  3. #2

    Default Re: Invalid attempt to read when no data is present.

    Looks like there were no rows returned. dr1.Read returned false.

    "Helixpoint" <dave@helixpoint.com> wrote in message
    news:OyEoEjBPDHA.2228@tk2msftngp13.phx.gbl...
    > Dim dr1 As SqlDataReader = MachCodeListID.GetSingleMachCode(thecodesID)
    >
    > ' Read first row from database
    >
    > dr1.Read()
    >
    > If IsDBNull(dr1("CATNUM")) Then '**************** This is where I am
    getting
    > the error??????
    >
    > thecatnum = 0
    >
    > Else
    >
    > thecatnum = dr1("CATNUM")
    >
    > End If
    >
    >
    > --
    >
    > ______________________
    > David Fetrow
    > HelixPoint LLC.
    > [url]http://www.helixpoint.com[/url]
    > [email]davef@helixpoint.com[/email]
    >
    > Interested in Affordable Email Marketing?
    > Check out the HelixMailer at [url]http://www.helixpoint.com/helixmailer.asp[/url]
    > If you are interested in becoming a Reseller of HelixPoint products,
    contact
    > [email]davef@helixpoint.com[/email]
    > ______________________
    >
    >

    Marina Guest

  4. #3

    Default Re: Invalid attempt to read when no data is present.

    Not to be a jerk, but I figured that out.


    "Marina" <zlatkinam@nospam.hotmail.com> wrote in message
    news:useiulBPDHA.2284@TK2MSFTNGP11.phx.gbl...
    > Looks like there were no rows returned. dr1.Read returned false.
    >
    > "Helixpoint" <dave@helixpoint.com> wrote in message
    > news:OyEoEjBPDHA.2228@tk2msftngp13.phx.gbl...
    > > Dim dr1 As SqlDataReader = MachCodeListID.GetSingleMachCode(thecodesID)
    > >
    > > ' Read first row from database
    > >
    > > dr1.Read()
    > >
    > > If IsDBNull(dr1("CATNUM")) Then '**************** This is where I am
    > getting
    > > the error??????
    > >
    > > thecatnum = 0
    > >
    > > Else
    > >
    > > thecatnum = dr1("CATNUM")
    > >
    > > End If
    > >
    > >
    > > --
    > >
    > > ______________________
    > > David Fetrow
    > > HelixPoint LLC.
    > > [url]http://www.helixpoint.com[/url]
    > > [email]davef@helixpoint.com[/email]
    > >
    > > Interested in Affordable Email Marketing?
    > > Check out the HelixMailer at [url]http://www.helixpoint.com/helixmailer.asp[/url]
    > > If you are interested in becoming a Reseller of HelixPoint products,
    > contact
    > > [email]davef@helixpoint.com[/email]
    > > ______________________
    > >
    > >
    >
    >

    Helixpoint Guest

  5. #4

    Default Re: Invalid attempt to read when no data is present.

    If you figured out that no rows were returned, then what's the problem?

    "Helixpoint" <dave@helixpoint.com> wrote in message
    news:OT6UkqBPDHA.2788@TK2MSFTNGP10.phx.gbl...
    > Not to be a jerk, but I figured that out.
    >
    >
    > "Marina" <zlatkinam@nospam.hotmail.com> wrote in message
    > news:useiulBPDHA.2284@TK2MSFTNGP11.phx.gbl...
    > > Looks like there were no rows returned. dr1.Read returned false.
    > >
    > > "Helixpoint" <dave@helixpoint.com> wrote in message
    > > news:OyEoEjBPDHA.2228@tk2msftngp13.phx.gbl...
    > > > Dim dr1 As SqlDataReader =
    MachCodeListID.GetSingleMachCode(thecodesID)
    > > >
    > > > ' Read first row from database
    > > >
    > > > dr1.Read()
    > > >
    > > > If IsDBNull(dr1("CATNUM")) Then '**************** This is where I am
    > > getting
    > > > the error??????
    > > >
    > > > thecatnum = 0
    > > >
    > > > Else
    > > >
    > > > thecatnum = dr1("CATNUM")
    > > >
    > > > End If
    > > >
    > > >
    > > > --
    > > >
    > > > ______________________
    > > > David Fetrow
    > > > HelixPoint LLC.
    > > > [url]http://www.helixpoint.com[/url]
    > > > [email]davef@helixpoint.com[/email]
    > > >
    > > > Interested in Affordable Email Marketing?
    > > > Check out the HelixMailer at [url]http://www.helixpoint.com/helixmailer.asp[/url]
    > > > If you are interested in becoming a Reseller of HelixPoint products,
    > > contact
    > > > [email]davef@helixpoint.com[/email]
    > > > ______________________
    > > >
    > > >
    > >
    > >
    >
    >

    Marina Guest

  6. #5

    Default Re: Invalid attempt to read when no data is present.

    I get an error when it checks for NULL???



    "Marina" <zlatkinam@nospam.hotmail.com> wrote in message
    news:unyL3sBPDHA.2228@tk2msftngp13.phx.gbl...
    > If you figured out that no rows were returned, then what's the problem?
    >
    > "Helixpoint" <dave@helixpoint.com> wrote in message
    > news:OT6UkqBPDHA.2788@TK2MSFTNGP10.phx.gbl...
    > > Not to be a jerk, but I figured that out.
    > >
    > >
    > > "Marina" <zlatkinam@nospam.hotmail.com> wrote in message
    > > news:useiulBPDHA.2284@TK2MSFTNGP11.phx.gbl...
    > > > Looks like there were no rows returned. dr1.Read returned false.
    > > >
    > > > "Helixpoint" <dave@helixpoint.com> wrote in message
    > > > news:OyEoEjBPDHA.2228@tk2msftngp13.phx.gbl...
    > > > > Dim dr1 As SqlDataReader =
    > MachCodeListID.GetSingleMachCode(thecodesID)
    > > > >
    > > > > ' Read first row from database
    > > > >
    > > > > dr1.Read()
    > > > >
    > > > > If IsDBNull(dr1("CATNUM")) Then '**************** This is where I am
    > > > getting
    > > > > the error??????
    > > > >
    > > > > thecatnum = 0
    > > > >
    > > > > Else
    > > > >
    > > > > thecatnum = dr1("CATNUM")
    > > > >
    > > > > End If
    > > > >
    > > > >
    > > > > --
    > > > >
    > > > > ______________________
    > > > > David Fetrow
    > > > > HelixPoint LLC.
    > > > > [url]http://www.helixpoint.com[/url]
    > > > > [email]davef@helixpoint.com[/email]
    > > > >
    > > > > Interested in Affordable Email Marketing?
    > > > > Check out the HelixMailer at
    [url]http://www.helixpoint.com/helixmailer.asp[/url]
    > > > > If you are interested in becoming a Reseller of HelixPoint products,
    > > > contact
    > > > > [email]davef@helixpoint.com[/email]
    > > > > ______________________
    > > > >
    > > > >
    > > >
    > > >
    > >
    > >
    >
    >

    Helixpoint Guest

  7. #6

    Default Re: Invalid attempt to read when no data is present.

    If there was no row returned, there is now way to check if a column in that
    row is null - because there is no row in the first place!!!

    "Helixpoint" <dave@helixpoint.com> wrote in message
    news:%23zB3lvBPDHA.3836@tk2msftngp13.phx.gbl...
    > I get an error when it checks for NULL???
    >
    >
    >
    > "Marina" <zlatkinam@nospam.hotmail.com> wrote in message
    > news:unyL3sBPDHA.2228@tk2msftngp13.phx.gbl...
    > > If you figured out that no rows were returned, then what's the problem?
    > >
    > > "Helixpoint" <dave@helixpoint.com> wrote in message
    > > news:OT6UkqBPDHA.2788@TK2MSFTNGP10.phx.gbl...
    > > > Not to be a jerk, but I figured that out.
    > > >
    > > >
    > > > "Marina" <zlatkinam@nospam.hotmail.com> wrote in message
    > > > news:useiulBPDHA.2284@TK2MSFTNGP11.phx.gbl...
    > > > > Looks like there were no rows returned. dr1.Read returned false.
    > > > >
    > > > > "Helixpoint" <dave@helixpoint.com> wrote in message
    > > > > news:OyEoEjBPDHA.2228@tk2msftngp13.phx.gbl...
    > > > > > Dim dr1 As SqlDataReader =
    > > MachCodeListID.GetSingleMachCode(thecodesID)
    > > > > >
    > > > > > ' Read first row from database
    > > > > >
    > > > > > dr1.Read()
    > > > > >
    > > > > > If IsDBNull(dr1("CATNUM")) Then '**************** This is where I
    am
    > > > > getting
    > > > > > the error??????
    > > > > >
    > > > > > thecatnum = 0
    > > > > >
    > > > > > Else
    > > > > >
    > > > > > thecatnum = dr1("CATNUM")
    > > > > >
    > > > > > End If
    > > > > >
    > > > > >
    > > > > > --
    > > > > >
    > > > > > ______________________
    > > > > > David Fetrow
    > > > > > HelixPoint LLC.
    > > > > > [url]http://www.helixpoint.com[/url]
    > > > > > [email]davef@helixpoint.com[/email]
    > > > > >
    > > > > > Interested in Affordable Email Marketing?
    > > > > > Check out the HelixMailer at
    > [url]http://www.helixpoint.com/helixmailer.asp[/url]
    > > > > > If you are interested in becoming a Reseller of HelixPoint
    products,
    > > > > contact
    > > > > > [email]davef@helixpoint.com[/email]
    > > > > > ______________________
    > > > > >
    > > > > >
    > > > >
    > > > >
    > > >
    > > >
    > >
    > >
    >
    >

    Marina Guest

  8. #7

    Default Re: Invalid attempt to read when no data is present.

    There is no point to doing that. dr1.Read returned false - hence no rows.
    Neither of these things will work. The structure needs to be

    If dr1.Read() Then

    If IsDbNull(dr1("Catnum") Then
    .....
    End If

    End If
    <daphish@msn.com> wrote in message
    news:h0kmfv4iodtvt10qe8n4tracbsjl42f7ao@4ax.com...
    > There is a difference between dbnull and the object being null. You
    > also need to check if the object doesn't exists as well
    >
    > if not dr1("Catnum") is vbnullstring orelse isdbnull(dr1("catnum")
    > then
    >
    >
    > -dwayne
    >
    >
    > On Thu, 26 Jun 2003 15:47:53 -0400, "Helixpoint" <dave@helixpoint.com>
    > wrote:
    >
    > >I get an error when it checks for NULL???
    > >
    > >
    > >
    > >"Marina" <zlatkinam@nospam.hotmail.com> wrote in message
    > >news:unyL3sBPDHA.2228@tk2msftngp13.phx.gbl...
    > >> If you figured out that no rows were returned, then what's the problem?
    > >>
    > >> "Helixpoint" <dave@helixpoint.com> wrote in message
    > >> news:OT6UkqBPDHA.2788@TK2MSFTNGP10.phx.gbl...
    > >> > Not to be a jerk, but I figured that out.
    > >> >
    > >> >
    > >> > "Marina" <zlatkinam@nospam.hotmail.com> wrote in message
    > >> > news:useiulBPDHA.2284@TK2MSFTNGP11.phx.gbl...
    > >> > > Looks like there were no rows returned. dr1.Read returned false.
    > >> > >
    > >> > > "Helixpoint" <dave@helixpoint.com> wrote in message
    > >> > > news:OyEoEjBPDHA.2228@tk2msftngp13.phx.gbl...
    > >> > > > Dim dr1 As SqlDataReader =
    > >> MachCodeListID.GetSingleMachCode(thecodesID)
    > >> > > >
    > >> > > > ' Read first row from database
    > >> > > >
    > >> > > > dr1.Read()
    > >> > > >
    > >> > > > If IsDBNull(dr1("CATNUM")) Then '**************** This is where I
    am
    > >> > > getting
    > >> > > > the error??????
    > >> > > >
    > >> > > > thecatnum = 0
    > >> > > >
    > >> > > > Else
    > >> > > >
    > >> > > > thecatnum = dr1("CATNUM")
    > >> > > >
    > >> > > > End If
    > >> > > >
    > >> > > >
    > >> > > > --
    > >> > > >
    > >> > > > ______________________
    > >> > > > David Fetrow
    > >> > > > HelixPoint LLC.
    > >> > > > [url]http://www.helixpoint.com[/url]
    > >> > > > [email]davef@helixpoint.com[/email]
    > >> > > >
    > >> > > > Interested in Affordable Email Marketing?
    > >> > > > Check out the HelixMailer at
    > >[url]http://www.helixpoint.com/helixmailer.asp[/url]
    > >> > > > If you are interested in becoming a Reseller of HelixPoint
    products,
    > >> > > contact
    > >> > > > [email]davef@helixpoint.com[/email]
    > >> > > > ______________________
    > >> > > >
    > >> > > >
    > >> > >
    > >> > >
    > >> >
    > >> >
    > >>
    > >>
    > >
    >

    Marina Guest

  9. #8

    Default Re: Invalid attempt to read when no data is present.

    oops my bad you could do it as
    dr1("catnum") is nothing

    On Thu, 26 Jun 2003 16:10:41 -0400, "Marina"
    <zlatkinam@nospam.hotmail.com> wrote:
    >There is no point to doing that. dr1.Read returned false - hence no rows.
    >Neither of these things will work. The structure needs to be
    >
    >If dr1.Read() Then
    >
    >If IsDbNull(dr1("Catnum") Then
    >....
    >End If
    >
    >End If
    ><daphish@msn.com> wrote in message
    >news:h0kmfv4iodtvt10qe8n4tracbsjl42f7ao@4ax.com.. .
    >> There is a difference between dbnull and the object being null. You
    >> also need to check if the object doesn't exists as well
    >>
    >> if not dr1("Catnum") is vbnullstring orelse isdbnull(dr1("catnum")
    >> then
    >>
    >>
    >> -dwayne
    >>
    >>
    >> On Thu, 26 Jun 2003 15:47:53 -0400, "Helixpoint" <dave@helixpoint.com>
    >> wrote:
    >>
    >> >I get an error when it checks for NULL???
    >> >
    >> >
    >> >
    >> >"Marina" <zlatkinam@nospam.hotmail.com> wrote in message
    >> >news:unyL3sBPDHA.2228@tk2msftngp13.phx.gbl...
    >> >> If you figured out that no rows were returned, then what's the problem?
    >> >>
    >> >> "Helixpoint" <dave@helixpoint.com> wrote in message
    >> >> news:OT6UkqBPDHA.2788@TK2MSFTNGP10.phx.gbl...
    >> >> > Not to be a jerk, but I figured that out.
    >> >> >
    >> >> >
    >> >> > "Marina" <zlatkinam@nospam.hotmail.com> wrote in message
    >> >> > news:useiulBPDHA.2284@TK2MSFTNGP11.phx.gbl...
    >> >> > > Looks like there were no rows returned. dr1.Read returned false.
    >> >> > >
    >> >> > > "Helixpoint" <dave@helixpoint.com> wrote in message
    >> >> > > news:OyEoEjBPDHA.2228@tk2msftngp13.phx.gbl...
    >> >> > > > Dim dr1 As SqlDataReader =
    >> >> MachCodeListID.GetSingleMachCode(thecodesID)
    >> >> > > >
    >> >> > > > ' Read first row from database
    >> >> > > >
    >> >> > > > dr1.Read()
    >> >> > > >
    >> >> > > > If IsDBNull(dr1("CATNUM")) Then '**************** This is where I
    >am
    >> >> > > getting
    >> >> > > > the error??????
    >> >> > > >
    >> >> > > > thecatnum = 0
    >> >> > > >
    >> >> > > > Else
    >> >> > > >
    >> >> > > > thecatnum = dr1("CATNUM")
    >> >> > > >
    >> >> > > > End If
    >> >> > > >
    >> >> > > >
    >> >> > > > --
    >> >> > > >
    >> >> > > > ______________________
    >> >> > > > David Fetrow
    >> >> > > > HelixPoint LLC.
    >> >> > > > [url]http://www.helixpoint.com[/url]
    >> >> > > > [email]davef@helixpoint.com[/email]
    >> >> > > >
    >> >> > > > Interested in Affordable Email Marketing?
    >> >> > > > Check out the HelixMailer at
    >> >[url]http://www.helixpoint.com/helixmailer.asp[/url]
    >> >> > > > If you are interested in becoming a Reseller of HelixPoint
    >products,
    >> >> > > contact
    >> >> > > > [email]davef@helixpoint.com[/email]
    >> >> > > > ______________________
    >> >> > > >
    >> >> > > >
    >> >> > >
    >> >> > >
    >> >> >
    >> >> >
    >> >>
    >> >>
    >> >
    >>
    >
    daphish@msn.com Guest

  10. #9

    Default Re: Invalid attempt to read when no data is present.

    No, my point is you could not do anything that would mean getting the column
    value from the datareader.

    The mere call to dr1("catnum") raises the error. There is no row - so no
    column value for "catnum" - because there is no row!!

    That's why the if statement for dr1.Read - to make sure there is a row
    before you try to look at one of its columns.

    <daphish@msn.com> wrote in message
    news:oklmfvgnfogaigdbpu50t8udcg4h4jnu6u@4ax.com...
    > oops my bad you could do it as
    > dr1("catnum") is nothing
    >
    > On Thu, 26 Jun 2003 16:10:41 -0400, "Marina"
    > <zlatkinam@nospam.hotmail.com> wrote:
    >
    > >There is no point to doing that. dr1.Read returned false - hence no
    rows.
    > >Neither of these things will work. The structure needs to be
    > >
    > >If dr1.Read() Then
    > >
    > >If IsDbNull(dr1("Catnum") Then
    > >....
    > >End If
    > >
    > >End If
    > ><daphish@msn.com> wrote in message
    > >news:h0kmfv4iodtvt10qe8n4tracbsjl42f7ao@4ax.com.. .
    > >> There is a difference between dbnull and the object being null. You
    > >> also need to check if the object doesn't exists as well
    > >>
    > >> if not dr1("Catnum") is vbnullstring orelse isdbnull(dr1("catnum")
    > >> then
    > >>
    > >>
    > >> -dwayne
    > >>
    > >>
    > >> On Thu, 26 Jun 2003 15:47:53 -0400, "Helixpoint" <dave@helixpoint.com>
    > >> wrote:
    > >>
    > >> >I get an error when it checks for NULL???
    > >> >
    > >> >
    > >> >
    > >> >"Marina" <zlatkinam@nospam.hotmail.com> wrote in message
    > >> >news:unyL3sBPDHA.2228@tk2msftngp13.phx.gbl...
    > >> >> If you figured out that no rows were returned, then what's the
    problem?
    > >> >>
    > >> >> "Helixpoint" <dave@helixpoint.com> wrote in message
    > >> >> news:OT6UkqBPDHA.2788@TK2MSFTNGP10.phx.gbl...
    > >> >> > Not to be a jerk, but I figured that out.
    > >> >> >
    > >> >> >
    > >> >> > "Marina" <zlatkinam@nospam.hotmail.com> wrote in message
    > >> >> > news:useiulBPDHA.2284@TK2MSFTNGP11.phx.gbl...
    > >> >> > > Looks like there were no rows returned. dr1.Read returned false.
    > >> >> > >
    > >> >> > > "Helixpoint" <dave@helixpoint.com> wrote in message
    > >> >> > > news:OyEoEjBPDHA.2228@tk2msftngp13.phx.gbl...
    > >> >> > > > Dim dr1 As SqlDataReader =
    > >> >> MachCodeListID.GetSingleMachCode(thecodesID)
    > >> >> > > >
    > >> >> > > > ' Read first row from database
    > >> >> > > >
    > >> >> > > > dr1.Read()
    > >> >> > > >
    > >> >> > > > If IsDBNull(dr1("CATNUM")) Then '**************** This is
    where I
    > >am
    > >> >> > > getting
    > >> >> > > > the error??????
    > >> >> > > >
    > >> >> > > > thecatnum = 0
    > >> >> > > >
    > >> >> > > > Else
    > >> >> > > >
    > >> >> > > > thecatnum = dr1("CATNUM")
    > >> >> > > >
    > >> >> > > > End If
    > >> >> > > >
    > >> >> > > >
    > >> >> > > > --
    > >> >> > > >
    > >> >> > > > ______________________
    > >> >> > > > David Fetrow
    > >> >> > > > HelixPoint LLC.
    > >> >> > > > [url]http://www.helixpoint.com[/url]
    > >> >> > > > [email]davef@helixpoint.com[/email]
    > >> >> > > >
    > >> >> > > > Interested in Affordable Email Marketing?
    > >> >> > > > Check out the HelixMailer at
    > >> >[url]http://www.helixpoint.com/helixmailer.asp[/url]
    > >> >> > > > If you are interested in becoming a Reseller of HelixPoint
    > >products,
    > >> >> > > contact
    > >> >> > > > [email]davef@helixpoint.com[/email]
    > >> >> > > > ______________________
    > >> >> > > >
    > >> >> > > >
    > >> >> > >
    > >> >> > >
    > >> >> >
    > >> >> >
    > >> >>
    > >> >>
    > >> >
    > >>
    > >
    >

    Marina Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139