473,508 Members | 4,179 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 35561
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
5194
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
2352
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
683
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
4696
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
3464
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
6510
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
1750
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
1879
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
4976
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
7228
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7128
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7502
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5635
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3206
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3191
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1565
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
769
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
426
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.