当多个用户访问同一数据库时发生错误 [英] Error when multiple user access same database

查看:105
本文介绍了当多个用户访问同一数据库时发生错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是将我的网站部署在IIS中,但是当多个用户访问我的数据库时,它就会出错..

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.




那我该怎么办?

如果有解决方案,请告诉我....
请帮帮我..
Mitesh




so what can i do ?

if there is solution please Tell Me....
Please Help Me..
Mitesh

推荐答案

取决于您使用的数据库类型以及如何连接它:如果它是SQLCe数据库,则只有一个用户可以访问它例如一次.如果它是一个Access数据库,并且通过ODBC进行连接,则理论上可以有多个用户使用它,但是-在实践中,这很快就很麻烦,而且效果也不佳.
如果它是一个SQL数据库,则假定在SQL端有足够的可用连接(并且一次最多只能有32,767个限制,但是在达到此水平之前,您将用光资源)好的-但是,数据库管理员如果想提高SQL性能,可以设置连接数限制.

检查您的代码:查看您的堆栈跟踪,并查看连接是否已打开.如果不是,请查看连接字符串是什么,然后检查一切是否正常.

抱歉,不能确定,但​​是有了您提供给我们的信息,我再确切不过了.
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.


做一件事

1.在打开连接之前,请先关闭连接,然后再重新打开它

do one thing

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

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











or

if (connectionobject.State == ConnectionState.Closed)
                   connectionobject.Open();


这篇关于当多个用户访问同一数据库时发生错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆