Click here to Skip to main content
15,905,068 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i just deploy my website in IIS but when mutiple user access my database so it gives error..

ExecuteReader requires an open and available Connection. The connection's current state is connecting.
 
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: ExecuteReader requires an open and available Connection. The connection's current state is connecting.
 
Source Error: 
 
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.



so what can i do ?

if there is solution please Tell Me....
Please Help Me..
Mitesh
Posted
Updated 26-May-12 10:51am
v3

Depends on what kind of database you are using, and how you are connecting to it: If it is an SQLCe database, then only one user can access it at a time, for example. If it is an Access database and you connect via ODBC, then in theory multiple users can use it, - but in practice this rapidly becomes a pain and doesn't work too well.
If it is an SQL database, then assuming there are sufficient connections available at the SQL end (and there is a limit of 32,767 in total at any one time, but you will run out of resources before you get anywhere near this) you should be ok - but the DB admin can set a connections count limit if he wants to to improve SQL performance.

Check your code: Look at your stack trace, and see if the connection has been opened. If not, look at what the connection string is, and check everything is ok there.

Sorry to be vague, but with the info you gave us, I can't be more exact.
 
Share this answer
 
Comments
[no name] 26-May-12 5:16am    
i use sql server database. but when more than two user access my database with different table it gives error...
OriginalGriff 26-May-12 5:26am    
What is your connection code?
[no name] 26-May-12 5:27am    
public void setcon()
{
try
{

con = new SqlConnection();
con.ConnectionString = @"Data Source=DATA-SERVER;Initial Catalog=fmweb;User ID=sa";
if (con.State == ConnectionState.Closed)
{
con.Open();
}
}
catch (Exception e1)
{
if (con.State != ConnectionState.Closed)
con.Close();
}


}

use Appcode in Class file.
and on every page load :
if (!IsPostBack)
{
c.setcon();
}
OriginalGriff 26-May-12 5:30am    
Is "con" static or class instance?
[no name] 26-May-12 5:57am    
public static SqlConnection con;
do one thing

1. before you are opening the connection close the connection and reopen it like this

C#
if (connectionobject.State == ConnectionState.Open)
                    connectionobject.Close();
                connectionobject.Open();




or

C#
if (connectionobject.State == ConnectionState.Closed)
                   connectionobject.Open();
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900