Sql数据读取器错误在同一个应用程序上唤醒多个人。 [英] Sql Data reader error While woking more than one person on the Same App.
问题描述
大家好。我有以下问题。我开发了Web应用程序。当单个用户工作时,它正在工作。
当多个用户使用相同的应用程序时。它会给出类似'Sql Data Reader Error'的消息。为此,我在Web配置文件的连接字符串中写了选项'MultipleActiveResultSets = True'。它也没有用。
---->所以我想执行请求[即请求来自不同的用户]一个接一个没有中断。请给出代码以及我为此编写以下代码。
public void CreateConnection ()
{
if(_Connection == null)
{
string Connection = ConnectionStrings.ConnectionString;
_Connection = new SqlConnection(Connection);
// _ Connection.Open();
}
}
public void OpenConnection()
{
CreateConnection();
if(_Connection.State!= ConnectionState.Open)
_Connection.Open();
}
public void CloseConnection()
{
if(_Connection.State == ConnectionState.Open)
_Connection.Close();
}
public DataTable GetTableByQuery(string Qry)
{
CreateConnection();
DataTable _table = new DataTable();
SqlDataAdapter _adapter = new SqlDataAdapter(Qry,_ Connect);
使用(_adapter)
{
//试试
{
_adapter.Fill(_table);
int count = _table.Rows.Count;
}
// catch(System.Exception e)
// {
// string msg = e.Message;
//}
}
返回_table;
}
< blockquote>请点击此链接。
http:// stackoverflo w.com/questions/17552829/c-sharp-data-connections-best-practice [ ^ ]
Hi To All. i have the following Problem . i had developed the web application . it is working when single user working it is good.
When More Than One User Working on The Same Application . it will gave the message like 'Sql Data Reader Error'. For that i had wrote the Option 'MultipleActiveResultSets=True' in Connection String of Web Config File. it is also not working.
----> So I Want To Execute The Request[i.e Requests are got fom the diffeent users] One by One Without Interruption. Please Give The Code As well as i Wrote the Following Code for that.
public void CreateConnection()
{
if (_Connection == null)
{
string Connection = ConnectionStrings.ConnectionString;
_Connection = new SqlConnection(Connection);
//_Connection.Open();
}
}
public void OpenConnection()
{
CreateConnection();
if(_Connection.State != ConnectionState.Open)
_Connection.Open();
}
public void CloseConnection()
{
if(_Connection.State == ConnectionState.Open)
_Connection.Close();
}
public DataTable GetTableByQuery(string Qry)
{
CreateConnection();
DataTable _table = new DataTable();
SqlDataAdapter _adapter = new SqlDataAdapter(Qry,_Connection);
using (_adapter)
{
//try
{
_adapter.Fill(_table);
int count = _table.Rows.Count;
}
//catch (System.Exception e)
//{
// string msg = e.Message;
//}
}
return _table;
}
Please follow this link.
http://stackoverflow.com/questions/17552829/c-sharp-data-connections-best-practice[^]
这篇关于Sql数据读取器错误在同一个应用程序上唤醒多个人。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!