473,320 Members | 2,052 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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
8 35545
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Brent Burkart | last post by:
Below is the error I am receiving. I have checked SQL Profiler and it is receiving the correct query which runs fine in Query Analyzer. Any ideas? Server Error in '/lockinsheet' Application....
2
by: Matthew Louden | last post by:
I want to read how many records in the table, and insert a record with id field which increment the counter by 1. However, I had the following runtime on Dim s As Integer = CInt(dr("t")). Since "t"...
0
by: Jerry | last post by:
Below is ALL the code for all the databases... Here's the problem: I callup the aspx file in IE and the form comes up just fine. When I select a person to update, I get the subject error. ...
0
by: phplasma | last post by:
Hey, I am currently attempting to implement a multi-threaded C# socket, using SSL (.pem file/certification/private key combo) server using Visual Studio C# Express. I have successfully made...
4
by: MarkusR | last post by:
If I run the stored proc in the Query Analyzer this works and I get the expected result set back. However when I run it in my application I get a results set of one row but when I try to access the...
3
by: divsTiw | last post by:
I want to populate combo box with data from OracleDataReader , but "Invalid attempt to read when no data is present." is thrown. there are two rows returned , then too why such error. plzzz...
2
by: Naty | last post by:
please can anybody help me? i'm trying to retrieve data from a db with visual studio 2005 and sql server 2000 in a web application, and the error "Invalid attempt to read when no data is present"...
1
Oodles Of Noodles
by: Oodles Of Noodles | last post by:
Hello fellow geeks I have a problem in my database iVB .Net program that is generating 'Error:Invalid attempt to read when no data is present.' The weird part is that when you call the page from...
6
by: =?Utf-8?B?ZWdzZGFy?= | last post by:
How can I solve this error: Invalid attempt to read when no data is present. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.