467,075 Members | 975 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,075 developers. It's quick & easy.

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.
http://www.helixpoint.com
da***@helixpoint.com

Interested in Affordable Email Marketing?
Check out the HelixMailer at http://www.helixpoint.com/helixmailer.asp
If you are interested in becoming a Reseller of HelixPoint products, contact
da***@helixpoint.com
______________________
Nov 17 '05 #1
  • viewed: 35030
Share:
8 Replies
Looks like there were no rows returned. dr1.Read returned false.

"Helixpoint" <da**@helixpoint.com> wrote in message
news:Oy**************@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.
http://www.helixpoint.com
da***@helixpoint.com

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

Nov 17 '05 #2
Not to be a jerk, but I figured that out.
"Marina" <zl*******@nospam.hotmail.com> wrote in message
news:us**************@TK2MSFTNGP11.phx.gbl...
Looks like there were no rows returned. dr1.Read returned false.

"Helixpoint" <da**@helixpoint.com> wrote in message
news:Oy**************@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.
http://www.helixpoint.com
da***@helixpoint.com

Interested in Affordable Email Marketing?
Check out the HelixMailer at http://www.helixpoint.com/helixmailer.asp
If you are interested in becoming a Reseller of HelixPoint products,

contact
da***@helixpoint.com
______________________


Nov 17 '05 #3
If you figured out that no rows were returned, then what's the problem?

"Helixpoint" <da**@helixpoint.com> wrote in message
news:OT**************@TK2MSFTNGP10.phx.gbl...
Not to be a jerk, but I figured that out.
"Marina" <zl*******@nospam.hotmail.com> wrote in message
news:us**************@TK2MSFTNGP11.phx.gbl...
Looks like there were no rows returned. dr1.Read returned false.

"Helixpoint" <da**@helixpoint.com> wrote in message
news:Oy**************@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.
http://www.helixpoint.com
da***@helixpoint.com

Interested in Affordable Email Marketing?
Check out the HelixMailer at http://www.helixpoint.com/helixmailer.asp
If you are interested in becoming a Reseller of HelixPoint products,

contact
da***@helixpoint.com
______________________



Nov 17 '05 #4
I get an error when it checks for NULL???

"Marina" <zl*******@nospam.hotmail.com> wrote in message
news:un**************@tk2msftngp13.phx.gbl...
If you figured out that no rows were returned, then what's the problem?

"Helixpoint" <da**@helixpoint.com> wrote in message
news:OT**************@TK2MSFTNGP10.phx.gbl...
Not to be a jerk, but I figured that out.
"Marina" <zl*******@nospam.hotmail.com> wrote in message
news:us**************@TK2MSFTNGP11.phx.gbl...
Looks like there were no rows returned. dr1.Read returned false.

"Helixpoint" <da**@helixpoint.com> wrote in message
news:Oy**************@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.
> http://www.helixpoint.com
> da***@helixpoint.com
>
> Interested in Affordable Email Marketing?
> Check out the HelixMailer at http://www.helixpoint.com/helixmailer.asp > If you are interested in becoming a Reseller of HelixPoint products,
contact
> da***@helixpoint.com
> ______________________
>
>



Nov 17 '05 #5
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" <da**@helixpoint.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
I get an error when it checks for NULL???

"Marina" <zl*******@nospam.hotmail.com> wrote in message
news:un**************@tk2msftngp13.phx.gbl...
If you figured out that no rows were returned, then what's the problem?

"Helixpoint" <da**@helixpoint.com> wrote in message
news:OT**************@TK2MSFTNGP10.phx.gbl...
Not to be a jerk, but I figured that out.
"Marina" <zl*******@nospam.hotmail.com> wrote in message
news:us**************@TK2MSFTNGP11.phx.gbl...
> Looks like there were no rows returned. dr1.Read returned false.
>
> "Helixpoint" <da**@helixpoint.com> wrote in message
> news:Oy**************@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.
> > http://www.helixpoint.com
> > da***@helixpoint.com
> >
> > Interested in Affordable Email Marketing?
> > Check out the HelixMailer at http://www.helixpoint.com/helixmailer.asp > > If you are interested in becoming a Reseller of HelixPoint products, > contact
> > da***@helixpoint.com
> > ______________________
> >
> >
>
>



Nov 17 '05 #6
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
<da*****@msn.com> wrote in message
news:h0********************************@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" <da**@helixpoint.com>
wrote:
I get an error when it checks for NULL???

"Marina" <zl*******@nospam.hotmail.com> wrote in message
news:un**************@tk2msftngp13.phx.gbl...
If you figured out that no rows were returned, then what's the problem?

"Helixpoint" <da**@helixpoint.com> wrote in message
news:OT**************@TK2MSFTNGP10.phx.gbl...
> Not to be a jerk, but I figured that out.
>
>
> "Marina" <zl*******@nospam.hotmail.com> wrote in message
> news:us**************@TK2MSFTNGP11.phx.gbl...
> > Looks like there were no rows returned. dr1.Read returned false.
> >
> > "Helixpoint" <da**@helixpoint.com> wrote in message
> > news:Oy**************@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.
> > > http://www.helixpoint.com
> > > da***@helixpoint.com
> > >
> > > Interested in Affordable Email Marketing?
> > > Check out the HelixMailer at

http://www.helixpoint.com/helixmailer.asp
> > > If you are interested in becoming a Reseller of HelixPoint products, > > contact
> > > da***@helixpoint.com
> > > ______________________
> > >
> > >
> >
> >
>
>

Nov 17 '05 #7
oops my bad you could do it as
dr1("catnum") is nothing

On Thu, 26 Jun 2003 16:10:41 -0400, "Marina"
<zl*******@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
<da*****@msn.com> wrote in message
news:h0********************************@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" <da**@helixpoint.com>
wrote:
>I get an error when it checks for NULL???
>
>
>
>"Marina" <zl*******@nospam.hotmail.com> wrote in message
>news:un**************@tk2msftngp13.phx.gbl...
>> If you figured out that no rows were returned, then what's the problem?
>>
>> "Helixpoint" <da**@helixpoint.com> wrote in message
>> news:OT**************@TK2MSFTNGP10.phx.gbl...
>> > Not to be a jerk, but I figured that out.
>> >
>> >
>> > "Marina" <zl*******@nospam.hotmail.com> wrote in message
>> > news:us**************@TK2MSFTNGP11.phx.gbl...
>> > > Looks like there were no rows returned. dr1.Read returned false.
>> > >
>> > > "Helixpoint" <da**@helixpoint.com> wrote in message
>> > > news:Oy**************@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 Iam >> > > getting
>> > > > the error??????
>> > > >
>> > > > thecatnum = 0
>> > > >
>> > > > Else
>> > > >
>> > > > thecatnum = dr1("CATNUM")
>> > > >
>> > > > End If
>> > > >
>> > > >
>> > > > --
>> > > >
>> > > > ______________________
>> > > > David Fetrow
>> > > > HelixPoint LLC.
>> > > > http://www.helixpoint.com
>> > > > da***@helixpoint.com
>> > > >
>> > > > Interested in Affordable Email Marketing?
>> > > > Check out the HelixMailer at
>http://www.helixpoint.com/helixmailer.asp
>> > > > If you are interested in becoming a Reseller of HelixPointproducts, >> > > contact
>> > > > da***@helixpoint.com
>> > > > ______________________
>> > > >
>> > > >
>> > >
>> > >
>> >
>> >
>>
>>
>


Nov 17 '05 #8
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.

<da*****@msn.com> wrote in message
news:ok********************************@4ax.com...
oops my bad you could do it as
dr1("catnum") is nothing

On Thu, 26 Jun 2003 16:10:41 -0400, "Marina"
<zl*******@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
<da*****@msn.com> wrote in message
news:h0********************************@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" <da**@helixpoint.com>
wrote:

>I get an error when it checks for NULL???
>
>
>
>"Marina" <zl*******@nospam.hotmail.com> wrote in message
>news:un**************@tk2msftngp13.phx.gbl...
>> If you figured out that no rows were returned, then what's the problem? >>
>> "Helixpoint" <da**@helixpoint.com> wrote in message
>> news:OT**************@TK2MSFTNGP10.phx.gbl...
>> > Not to be a jerk, but I figured that out.
>> >
>> >
>> > "Marina" <zl*******@nospam.hotmail.com> wrote in message
>> > news:us**************@TK2MSFTNGP11.phx.gbl...
>> > > Looks like there were no rows returned. dr1.Read returned false.
>> > >
>> > > "Helixpoint" <da**@helixpoint.com> wrote in message
>> > > news:Oy**************@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 Iam
>> > > getting
>> > > > the error??????
>> > > >
>> > > > thecatnum = 0
>> > > >
>> > > > Else
>> > > >
>> > > > thecatnum = dr1("CATNUM")
>> > > >
>> > > > End If
>> > > >
>> > > >
>> > > > --
>> > > >
>> > > > ______________________
>> > > > David Fetrow
>> > > > HelixPoint LLC.
>> > > > http://www.helixpoint.com
>> > > > da***@helixpoint.com
>> > > >
>> > > > Interested in Affordable Email Marketing?
>> > > > Check out the HelixMailer at
>http://www.helixpoint.com/helixmailer.asp
>> > > > If you are interested in becoming a Reseller of HelixPoint

products,
>> > > contact
>> > > > da***@helixpoint.com
>> > > > ______________________
>> > > >
>> > > >
>> > >
>> > >
>> >
>> >
>>
>>
>

Nov 17 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by =?Utf-8?B?ZWdzZGFy?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.