SV: Cannot Read Reader
Messages   Related Types
This message was discovered on ASPFriends.com 'ngfx-sqlclient' list.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.

=?iso-8859-1?Q?Andr=E9_Colbi=F6rnsen?=
Where do you open (and close) the connection to your database?

Regards/Halsningar

Andre Colbiornsen
--------------------------------------
Sonnenburg Communications
Bergsgatan 3,
SE-211 54 Malm=F6
Sweden
Tel.: +46-(0)40-97 78 80
Fax.: +46-(0)40-97 78 80
Mob.: +46-(0)708-97 78 79
Mail: Click here to reveal e-mail address
Web.: www.sonnenburg.se
----------------------------------------
B2B Web Solutions - Specializing in .Net
----------------------------------------

-----Ursprungligt meddelande-----
Fr=E5n: Neil Moodley [mailto:Click here to reveal e-mail address]=20
Skickat: den 15 juli 2002 16:20
Till: ngfx-sqlclient
=C4mne: [ngfx-sqlclient] Cannot Read Reader

-- Moved from [aspngfreeforall] to [ngfx-sqlclient] by Tim Musschoot
<Click here to reveal e-mail address> --

Hi All

I am trying to retrieve data in a datareader. I know the stored
procedure is pulling data from sql server ok, but i am getting an
'Invalid attempt to Read when Reader is Closed' error message. here's my
code...

Dim drFilmLinks As SqlDataReader

    'returns datareader object from class method
drFilmLinks =3D objFilmLinks.getFilmLinks(intBrowseWhat)=20

While drFilmLinks.Read
    ' do stuff here...
End While

drFilmLinks.close()

any ideas ? this is a fairly direct copy and paste from another piece of
code that i wrote a while ago, and that is still working fine...

thanks all

neil

| [ngfx-sqlclient] member Click here to reveal e-mail address =3D YOUR ID=20
| http://www.aspfriends.com/aspfriends/ngfx-sqlclient.asp =3D JOIN/QUIT

Reply to this message...
 
    
Neil Moodley
in a class method.

basically i have a method that opens a connection to the db, runs a =
stored
procedure which retrieves some data, populates a datareader, which is =
then
returned to the code that called the method. once the datareader has =
been
returned, i then try and iterate through it, which is when i get the =
error
message.

thanks

Neil

-----Original Message-----
From: Andr=E9 Colbi=F6rnsen [mailto:Click here to reveal e-mail address]
Sent: 15 July 2002 15:28
To: ngfx-sqlclient
Subject: [ngfx-sqlclient] SV: Cannot Read Reader

Where do you open (and close) the connection to your database?

Regards/Halsningar

Andre Colbiornsen
--------------------------------------
Sonnenburg Communications
Bergsgatan 3,
SE-211 54 Malm=F6
Sweden
Tel.: +46-(0)40-97 78 80
Fax.: +46-(0)40-97 78 80
Mob.: +46-(0)708-97 78 79
Mail: Click here to reveal e-mail address
Web.: www.sonnenburg.se
----------------------------------------
B2B Web Solutions - Specializing in .Net
----------------------------------------

-----Ursprungligt meddelande-----
Fr=E5n: Neil Moodley [mailto:Click here to reveal e-mail address]=20
Skickat: den 15 juli 2002 16:20
Till: ngfx-sqlclient
=C4mne: [ngfx-sqlclient] Cannot Read Reader

-- Moved from [aspngfreeforall] to [ngfx-sqlclient] by Tim Musschoot
<Click here to reveal e-mail address> --

Hi All

I am trying to retrieve data in a datareader. I know the stored
procedure is pulling data from sql server ok, but i am getting an
'Invalid attempt to Read when Reader is Closed' error message. here's =
my
code...

Dim drFilmLinks As SqlDataReader

    'returns datareader object from class method
drFilmLinks =3D objFilmLinks.getFilmLinks(intBrowseWhat)=20

While drFilmLinks.Read
    ' do stuff here...
End While

drFilmLinks.close()

any ideas ? this is a fairly direct copy and paste from another piece =
of
code that i wrote a while ago, and that is still working fine...

thanks all

neil

| [ngfx-sqlclient] member Click here to reveal e-mail address =3D YOUR ID=20
| http://www.aspfriends.com/aspfriends/ngfx-sqlclient.asp =3D JOIN/QUIT

| [ngfx-sqlclient] member Click here to reveal e-mail address =3D YOUR ID
| http://www.aspfriends.com/aspfriends/ngfx-sqlclient.asp =3D JOIN/QUIT

Reply to this message...
 
    
Tim Musschoot
Please post the complete code of your procedure... =20

----- Original Message -----
From: Neil Moodley <Click here to reveal e-mail address>
To: Click here to reveal e-mail address
Sent: Mon, 15 Jul 2002 15:35:45 +0100
Subject: RE: [ngfx-sqlclient] SV: Cannot Read Reader
[Original message clipped]

Sent: 15 July 2002 15:28
To: ngfx-sqlclient
Subject: [ngfx-sqlclient] SV: Cannot Read Reader
[Original message clipped]

Reply to this message...
 
    
doug@accessmicrosystems.net (VIP)
Or failing that, in the self help category, he could
single step through the code and ENSURE that the code
he thinks is being executed is, and there are no
exceptions he is just swallowing up that would tell him
the problem...

On Mon, 15 July 2002, "Tim Musschoot" wrote

[Original message clipped]

=3D JOIN/QUIT
[Original message clipped]

=3D JOIN/QUIT
[Original message clipped]

=3D JOIN/QUIT
=0D
Douglas Reilly
Designing Microsoft(r) ASP.NET Applications
http://www.ProgrammingASP.net

Reply to this message...
 
    
Iain Smallwood
If your class method neatly closes the connection you will get this
error. If you use closeconnection command behaviour then you do not
close the connection, just wait until the datareader closes, when the
connection is then closed.

HTH,
Iain

-----Original Message-----
From: Neil Moodley [mailto:Click here to reveal e-mail address]=20
Sent: 15 July 2002 15:36
To: ngfx-sqlclient
Subject: [ngfx-sqlclient] RE: SV: Cannot Read Reader

in a class method.

basically i have a method that opens a connection to the db, runs a
stored procedure which retrieves some data, populates a datareader,
which is then returned to the code that called the method. once the
datareader has been returned, i then try and iterate through it, which
is when i get the error message.

thanks

Neil

-----Original Message-----
From: Andr=E9 Colbi=F6rnsen [mailto:Click here to reveal e-mail address]
Sent: 15 July 2002 15:28
To: ngfx-sqlclient
Subject: [ngfx-sqlclient] SV: Cannot Read Reader

Where do you open (and close) the connection to your database?

Regards/Halsningar

Andre Colbiornsen
--------------------------------------
Sonnenburg Communications
Bergsgatan 3,
SE-211 54 Malm=F6
Sweden
Tel.: +46-(0)40-97 78 80
Fax.: +46-(0)40-97 78 80
Mob.: +46-(0)708-97 78 79
Mail: Click here to reveal e-mail address
Web.: www.sonnenburg.se
----------------------------------------
B2B Web Solutions - Specializing in .Net
----------------------------------------

-----Ursprungligt meddelande-----
Fr=E5n: Neil Moodley [mailto:Click here to reveal e-mail address]=20
Skickat: den 15 juli 2002 16:20
Till: ngfx-sqlclient
=C4mne: [ngfx-sqlclient] Cannot Read Reader

-- Moved from [aspngfreeforall] to [ngfx-sqlclient] by Tim Musschoot
<Click here to reveal e-mail address> --

Hi All

I am trying to retrieve data in a datareader. I know the stored
procedure is pulling data from sql server ok, but i am getting an
'Invalid attempt to Read when Reader is Closed' error message. here's my
code...

Dim drFilmLinks As SqlDataReader

    'returns datareader object from class method
drFilmLinks =3D objFilmLinks.getFilmLinks(intBrowseWhat)=20

While drFilmLinks.Read
    ' do stuff here...
End While

drFilmLinks.close()

any ideas ? this is a fairly direct copy and paste from another piece of
code that i wrote a while ago, and that is still working fine...

thanks all

neil

| [ngfx-sqlclient] member Click here to reveal e-mail address =3D YOUR ID
| http://www.aspfriends.com/aspfriends/ngfx-sqlclient.asp =3D JOIN/QUIT

| [ngfx-sqlclient] member Click here to reveal e-mail address =3D YOUR ID
| http://www.aspfriends.com/aspfriends/ngfx-sqlclient.asp =3D JOIN/QUIT

| [ngfx-sqlclient] member Click here to reveal e-mail address =3D YOUR ID
| http://www.aspfriends.com/aspfriends/ngfx-sqlclient.asp =3D JOIN/QUIT
=20
Disclaimer
This message may contain information which is legally privileged and/or
confidential. If you are not the intended recipient, you are hereby
notified that any unauthorised disclosure, copying, distribution or use
of this information is strictly prohibited. Such notification not
withstanding, any comments or opinions expressed are those of the
originator, not of Taylor Made Computer Solutions, unless otherwise
explicitly stated.
=20
=20

Reply to this message...
 
    
Andy Kendall
I know this is an old problem but I recently had this problem and looked it up on google and found this, and I think I fixed it.. It was happening because somewhere in the middle of my "while objrdr.read" I had a sub that closed the reader.. so check everything inside the reader closely for anything that might close it.

--------------------------------
From: Andy Kendall
Reply to this message...
 
 
System.Data.SqlClient.SqlDataReader




Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
 
 Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us - Terms of Use - Privacy Policy - www.dotnet247.com