连接池超时的问题!!!
最近不知道为什么老是报数据库连接超时。
错误信息:error connecting: Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached.
根据这几天的测试估计是异步的时候导致连接没有关闭的问题。但是我检查了一些都没有发现。
public IAsyncResult IAsyncQuery(int id)
{
DataBase db = GetDataBase(DataBaseName);
using (DbConnection connection = db.CreateConnection())
{
connection.Open();
using (DbCommand command = db.GetSqlStringCommand(base["Select语句"]))
{
db.AddInParameter(command, "id", DbType.Int32, id);
return db.ExecuteAsyncDataReader(command, CommandBehavior.CloseConnection);
}
connection.Close();
}
}
恳请高手赐教。
本人新手没多少分,见谅!!