473,756 Members | 7,293 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 35582
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
5212
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
2375
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
4751
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
3475
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
6530
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
1759
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
1892
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
4990
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
9303
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9117
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9894
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
9679
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...
0
6390
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4955
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
5156
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3651
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
3
2508
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.