473,387 Members | 2,436 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,387 software developers and data experts.

"Executereader requires an open and available connection" error


I have an asp.net page that stopped running properly giving the error
below. The app uses a SQL Server 2000 on another server. Enterprise Manager
and Query analyzer on the web server can connect to that sql server just
fine and run queries. I rebooted the web server and made aspnet member of
the admin group. I don't know why the error mentions open connections if I
can open several query anaylzer windows using the same sql server
credentials as the asp.net is using.
I suspect it's an issue with ado.net or .net in general.

Any ideas?

error message:
"Executereader requires an open and available connection

Karim
Nov 17 '05 #1
6 4460
Whoa - don't go adding ASPNET to the admins group - that's a huge security
vulnerability!

First of all, you'll want to check your authentication. You can't use a
local account to use windows authentication to another machine - either use
a domain account or else use SQL Authentication (a domain account being the
more secure option, but if you have to use SQL authentication you can at
least encrypt your key using aspnet_setreg). Once you have that going, then
make sure you wrap the opening of your database connection in a try catch
block, and examine the error message that you receive for more information:

try {
conn.Open();
} catch (SqlException ex) {
#if (DEBUG)
Response.Write(ex.Message);
#else
// do something to handle the error in release mode that doesn't give
potential hackers too much info
#endif
} finally {
// do any cleanup
}
--
Chris Jackson
Software Engineer
Microsoft MVP - Windows XP
Windows XP Associate Expert
--
"karim" <ka*******@11yahoo11.com> wrote in message
news:1w*****************************@40tude.net...

I have an asp.net page that stopped running properly giving the error
below. The app uses a SQL Server 2000 on another server. Enterprise Manager and Query analyzer on the web server can connect to that sql server just
fine and run queries. I rebooted the web server and made aspnet member of
the admin group. I don't know why the error mentions open connections if I can open several query anaylzer windows using the same sql server
credentials as the asp.net is using.
I suspect it's an issue with ado.net or .net in general.

Any ideas?

error message:
"Executereader requires an open and available connection

Karim

Nov 17 '05 #2
It's saying that the datareader was closed in your code.

To use a datareader you:

1) declare a connection to the sql server
2) open that connection
3) execute the datareader
4) close the datareader

If your looping your code and trying to read a second time after the
connection is closed you would see this error.

Another possibility is if you put the connection object into an application
level variable, then while one user trys to open a connection another might
be closing it at the same time. In both cases you would see this error.

Or maybe you just forgot to open your connection.

Sincerely,

--
S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"karim" <ka*******@11yahoo11.com> wrote in message
news:1w*****************************@40tude.net...

I have an asp.net page that stopped running properly giving the error
below. The app uses a SQL Server 2000 on another server. Enterprise Manager and Query analyzer on the web server can connect to that sql server just
fine and run queries. I rebooted the web server and made aspnet member of
the admin group. I don't know why the error mentions open connections if I can open several query anaylzer windows using the same sql server
credentials as the asp.net is using.
I suspect it's an issue with ado.net or .net in general.

Any ideas?

error message:
"Executereader requires an open and available connection

Karim

Nov 17 '05 #3
On Wed, 13 Aug 2003 12:42:50 -0400, Chris Jackson wrote:
Whoa - don't go adding ASPNET to the admins group - that's a huge security
vulnerability!
I understand the implications. I am trying to troubleshoot. Plus the server
is an internal server.

First of all, you'll want to check your authentication. You can't use a
local account to use windows authentication to another machine - either use
a domain account or else use SQL Authentication (a domain account being the
more secure option, but if you have to use SQL authentication you can at
least encrypt your key using aspnet_setreg). Once you have that going, then
make sure you wrap the opening of your database connection in a try catch
block, and examine the error message that you receive for more information:

try {
conn.Open();
} catch (SqlException ex) {
#if (DEBUG)
Response.Write(ex.Message);
#else
// do something to handle the error in release mode that doesn't give
potential hackers too much info
#endif
} finally {
// do any cleanup
}


I am using sql authentication and the app used to work. The sql
authentication works as verified by using query analyzer.

karim
Nov 17 '05 #4
On Wed, 13 Aug 2003 11:47:55 -0500, S. Justin Gengo wrote:
It's saying that the datareader was closed in your code.

To use a datareader you:

1) declare a connection to the sql server
2) open that connection
3) execute the datareader
4) close the datareader

If your looping your code and trying to read a second time after the
connection is closed you would see this error.

Another possibility is if you put the connection object into an application
level variable, then while one user trys to open a connection another might
be closing it at the same time. In both cases you would see this error.

Or maybe you just forgot to open your connection.

Sincerely,


It's not the code. It used to work fine plus it works fine on my
development box connecting to the same sql server using the same sql
credentials. I recompiled and replaced the dll on the production box. Same
problem.

It has to be something in Windows or .net, a setting, permission or
something.

karim
Nov 17 '05 #5
> I am using sql authentication and the app used to work. The sql
authentication works as verified by using query analyzer.


The only thing I can think of is to step through your code. Make sure that
all of our code is being called as you expect. After you open the
connection, check it's state before stepping through the next line, etc.

--
Chris Jackson
Software Engineer
Microsoft MVP - Windows XP
Windows XP Associate Expert
--
Nov 17 '05 #6
On Wed, 13 Aug 2003 09:26:15 -0700, karim wrote:

I have an asp.net page that stopped running properly giving the error
below. The app uses a SQL Server 2000 on another server. Enterprise Manager
and Query analyzer on the web server can connect to that sql server just
fine and run queries. I rebooted the web server and made aspnet member of
the admin group. I don't know why the error mentions open connections if I
can open several query anaylzer windows using the same sql server
credentials as the asp.net is using.
I suspect it's an issue with ado.net or .net in general.

Any ideas?

error message:
"Executereader requires an open and available connection


I solved the problem but the I still need to know why my steps solved it.

The firewall log on the web server indicated SMB authentication errors to
the database server. The app used to work fine and nothing has changed
(afaik) and the firewall log hinted on permission or access problems. So I
changed the smpt, iis and iis admin services to run under the domain
administrator. The app worked! But I didn't want to keep this so I changed
them back to LocalSystem, restarted the services and it still worked. I
don't understand why all this made it happen. I appreicate any feedback.

karim
Nov 17 '05 #7

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

Similar topics

0
by: BGS | last post by:
I have a web site (www.on-the-matrix.com) that displays photos in a "slide show" format on ASPX pages that run in an inline frame on an ASP page (or in a separate pop-up window). The ASPX pages...
1
by: Lauchlan M | last post by:
I get the following error. Apart from the fact that it does not make any grammatical sense, what would be likely to be causing it? The background is that nxCmdDeleteErrorLogItem is a delete...
1
by: Lauchlan M | last post by:
I get the following error. Apart from the fact that it does not make any grammatical sense, what would be likely to be causing it? I have a command component 'nxCmdDeleteErrorLogItem' with the...
3
by: ITP | last post by:
Hello, I'm seeing this with the ADO.NET SQLClient provider: When I check the connection's open status after it has been opened AND has been broken (I simulate this by disconnecting the cable...
1
by: Charlie | last post by:
I am trying to make an XMLHttpRequest which violates the default "same- origin"policy in Firefox. I checked the archives and found a method that should work but it does not. Below is the test code...
2
by: Martin Z | last post by:
I'm using the TableAdapterHelper to set the connection and transaction properties on all the commands of all my typed table adapters.... I've checked at the time of the error and all the commands...
0
by: Ofelia | last post by:
Hi, I'm new to this forum and to Perl language but I would like to ask for your help. I'm working in Linux and the files I need to process are in the format “file.gz”. I created a script which...
8
jmoudy77
by: jmoudy77 | last post by:
Hi, I've got a form that allows a user to imput their flight data. I programmed a MsgBox into the save button that asks if the user wants to input another duty position for the flight. If no, the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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
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,...
0
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...

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.