473,700 Members | 2,453 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. GetSingleMachCo de(thecodesID)

' Read first row from database

dr1.Read()

If IsDBNull(dr1("C ATNUM")) 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***@helixpoin t.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***@helixpoin t.com
_______________ _______
Nov 17 '05 #1
8 35577
Looks like there were no rows returned. dr1.Read returned false.

"Helixpoint " <da**@helixpoin t.com> wrote in message
news:Oy******** ******@tk2msftn gp13.phx.gbl...
Dim dr1 As SqlDataReader = MachCodeListID. GetSingleMachCo de(thecodesID)

' Read first row from database

dr1.Read()

If IsDBNull(dr1("C ATNUM")) 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***@helixpoin t.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***@helixpoin t.com
_______________ _______

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

"Helixpoint " <da**@helixpoin t.com> wrote in message
news:Oy******** ******@tk2msftn gp13.phx.gbl...
Dim dr1 As SqlDataReader = MachCodeListID. GetSingleMachCo de(thecodesID)

' Read first row from database

dr1.Read()

If IsDBNull(dr1("C ATNUM")) 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***@helixpoin t.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***@helixpoin t.com
_______________ _______


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

"Helixpoint " <da**@helixpoin t.com> wrote in message
news:OT******** ******@TK2MSFTN GP10.phx.gbl...
Not to be a jerk, but I figured that out.
"Marina" <zl*******@nosp am.hotmail.com> wrote in message
news:us******** ******@TK2MSFTN GP11.phx.gbl...
Looks like there were no rows returned. dr1.Read returned false.

"Helixpoint " <da**@helixpoin t.com> wrote in message
news:Oy******** ******@tk2msftn gp13.phx.gbl...
Dim dr1 As SqlDataReader = MachCodeListID. GetSingleMachCo de(thecodesID)
' Read first row from database

dr1.Read()

If IsDBNull(dr1("C ATNUM")) 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***@helixpoin t.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***@helixpoin t.com
_______________ _______



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

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

"Helixpoint " <da**@helixpoin t.com> wrote in message
news:OT******** ******@TK2MSFTN GP10.phx.gbl...
Not to be a jerk, but I figured that out.
"Marina" <zl*******@nosp am.hotmail.com> wrote in message
news:us******** ******@TK2MSFTN GP11.phx.gbl...
Looks like there were no rows returned. dr1.Read returned false.

"Helixpoint " <da**@helixpoin t.com> wrote in message
news:Oy******** ******@tk2msftn gp13.phx.gbl...
> Dim dr1 As SqlDataReader = MachCodeListID. GetSingleMachCo de(thecodesID) >
> ' Read first row from database
>
> dr1.Read()
>
> If IsDBNull(dr1("C ATNUM")) 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***@helixpoin t.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***@helixpoin t.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**@helixpoin t.com> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
I get an error when it checks for NULL???

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

"Helixpoint " <da**@helixpoin t.com> wrote in message
news:OT******** ******@TK2MSFTN GP10.phx.gbl...
Not to be a jerk, but I figured that out.
"Marina" <zl*******@nosp am.hotmail.com> wrote in message
news:us******** ******@TK2MSFTN GP11.phx.gbl...
> Looks like there were no rows returned. dr1.Read returned false.
>
> "Helixpoint " <da**@helixpoin t.com> wrote in message
> news:Oy******** ******@tk2msftn gp13.phx.gbl...
> > Dim dr1 As SqlDataReader =

MachCodeListID. GetSingleMachCo de(thecodesID)
> >
> > ' Read first row from database
> >
> > dr1.Read()
> >
> > If IsDBNull(dr1("C ATNUM")) 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***@helixpoin t.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***@helixpoin t.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("C atnum") Then
.....
End If

End If
<da*****@msn.co m> wrote in message
news:h0******** *************** *********@4ax.c om...
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("c atnum")
then
-dwayne
On Thu, 26 Jun 2003 15:47:53 -0400, "Helixpoint " <da**@helixpoin t.com>
wrote:
I get an error when it checks for NULL???

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

"Helixpoint " <da**@helixpoin t.com> wrote in message
news:OT******** ******@TK2MSFTN GP10.phx.gbl...
> Not to be a jerk, but I figured that out.
>
>
> "Marina" <zl*******@nosp am.hotmail.com> wrote in message
> news:us******** ******@TK2MSFTN GP11.phx.gbl...
> > Looks like there were no rows returned. dr1.Read returned false.
> >
> > "Helixpoint " <da**@helixpoin t.com> wrote in message
> > news:Oy******** ******@tk2msftn gp13.phx.gbl...
> > > Dim dr1 As SqlDataReader =
MachCodeListID. GetSingleMachCo de(thecodesID)
> > >
> > > ' Read first row from database
> > >
> > > dr1.Read()
> > >
> > > If IsDBNull(dr1("C ATNUM")) 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***@helixpoin t.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***@helixpoin t.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*******@nosp am.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("C atnum") Then
....
End If

End If
<da*****@msn.c om> 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("c atnum")
then
-dwayne
On Thu, 26 Jun 2003 15:47:53 -0400, "Helixpoint " <da**@helixpoin t.com>
wrote:
>I get an error when it checks for NULL???
>
>
>
>"Marina" <zl*******@nosp am.hotmail.com> wrote in message
>news:un******* *******@tk2msft ngp13.phx.gbl.. .
>> If you figured out that no rows were returned, then what's the problem?
>>
>> "Helixpoint " <da**@helixpoin t.com> wrote in message
>> news:OT******** ******@TK2MSFTN GP10.phx.gbl...
>> > Not to be a jerk, but I figured that out.
>> >
>> >
>> > "Marina" <zl*******@nosp am.hotmail.com> wrote in message
>> > news:us******** ******@TK2MSFTN GP11.phx.gbl...
>> > > Looks like there were no rows returned. dr1.Read returned false.
>> > >
>> > > "Helixpoint " <da**@helixpoin t.com> wrote in message
>> > > news:Oy******** ******@tk2msftn gp13.phx.gbl...
>> > > > Dim dr1 As SqlDataReader =
>> MachCodeListID. GetSingleMachCo de(thecodesID)
>> > > >
>> > > > ' Read first row from database
>> > > >
>> > > > dr1.Read()
>> > > >
>> > > > If IsDBNull(dr1("C ATNUM")) 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***@helixpoin t.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***@helixpoin t.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.co m> wrote in message
news:ok******** *************** *********@4ax.c om...
oops my bad you could do it as
dr1("catnum") is nothing

On Thu, 26 Jun 2003 16:10:41 -0400, "Marina"
<zl*******@nosp am.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("C atnum") Then
....
End If

End If
<da*****@msn.c om> 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("c atnum")
then
-dwayne
On Thu, 26 Jun 2003 15:47:53 -0400, "Helixpoint " <da**@helixpoin t.com>
wrote:

>I get an error when it checks for NULL???
>
>
>
>"Marina" <zl*******@nosp am.hotmail.com> wrote in message
>news:un******* *******@tk2msft ngp13.phx.gbl.. .
>> If you figured out that no rows were returned, then what's the problem? >>
>> "Helixpoint " <da**@helixpoin t.com> wrote in message
>> news:OT******** ******@TK2MSFTN GP10.phx.gbl...
>> > Not to be a jerk, but I figured that out.
>> >
>> >
>> > "Marina" <zl*******@nosp am.hotmail.com> wrote in message
>> > news:us******** ******@TK2MSFTN GP11.phx.gbl...
>> > > Looks like there were no rows returned. dr1.Read returned false.
>> > >
>> > > "Helixpoint " <da**@helixpoin t.com> wrote in message
>> > > news:Oy******** ******@tk2msftn gp13.phx.gbl...
>> > > > Dim dr1 As SqlDataReader =
>> MachCodeListID. GetSingleMachCo de(thecodesID)
>> > > >
>> > > > ' Read first row from database
>> > > >
>> > > > dr1.Read()
>> > > >
>> > > > If IsDBNull(dr1("C ATNUM")) 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***@helixpoin t.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***@helixpoin t.com
>> > > > _______________ _______
>> > > >
>> > > >
>> > >
>> > >
>> >
>> >
>>
>>
>

Nov 17 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
5209
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. ---------------------------------------------------------------------------- ---- 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...
2
2372
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" (I want to represent the count, but just a tempoary variable, not a field in table) doesnt exist in the table sqlStmt = "SELECT COUNT(*) As t FROM TimeSlot;" cmd = New SqlCommand(sqlStmt, conn) cmd.Connection.Open()
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. Aparently, when I select a person, it's not selecting anyone and returning this error. Here's the full error: Description: An unhandled exception occurred during the execution of the
0
4748
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 the client application establish a connection, and send data, which appears in plain, de-crypted text on the server - this works.
4
3470
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 values I get "Invalid attempt to read when no data is present". private void GetLotIDPriorityFromLot(string aLotDesc, out int aLotID, out DateTime aPriorityDate) { SqlConnection Conn; SqlDataReader reader = null;
3
6527
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 share ur knowledge to help me out with this probs. my code is as below,
2
1757
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" keeps showing and i don't know why...i executed my stored procedure in the query analyzer and it's ok, i'm using the sentence "mydatareader.Read()" and it's working well....please, does anybody know what can i do?
1
1891
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 another page the script works yielding the desired records BUT WHEN YOU CALL THE SCRIPT AGAIN WHEN ATTEMPTING TO CALL THE SAME PAGE (PASSING DIFFERENT PARAMETERS USING QUERYSTRING ) THE QUERY DOESN'T YIELD ANY DATA Sub PropertyView( )
6
4987
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 trace for more information about the error and where it originated in the code. Exception Details: System.InvalidOperationException: Invalid attempt to read when no data is present. Source Error:
0
9214
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9075
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8973
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7810
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6561
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4404
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4657
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3089
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 we have to send another system
2
2392
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.