这很简单,我要做的就是填充一个数据表,我有使用()包围的所有内容,连接将不会处理/关闭。请帮忙
DataTable loginTbl = MySQLProcessing.MySQLProcessor.StoreProcedureDTTable("Login", ParamArgs, "Login");
public static DataTable StoreProcedureDTTable(string mysqlQuery, List<string> CommandArgs, string queryName)
{
DataTable DTTableTable = new DataTable();
using (MySqlCommand MySQLCommandFunc = new MySqlCommand(mysqlQuery))
{
MySQLCommandFunc.CommandType = CommandType.StoredProcedure;
foreach (string args in CommandArgs)
{
string[] splitArgs = args.Split('|');
MySQLCommandFunc.Parameters.AddWithValue(splitArgs[0], splitArgs[1]);
}
using (MySqlDataAdapter DataDTTables = new MySqlDataAdapter(MySQLCommandFunc))
{
DataDTTables.SelectCommand.CommandTimeout = 240000;
lock (_object)
{
using (MySqlConnection con = new MySqlConnection(ConfigurationManager.ConnectionStrings["mysqlCon"].ConnectionString))
{
MySQLCommandFunc.Connection = con;
DataDTTables.Fill(DTTableTable);
}
}
}
}
DataTable catchConnectionTable = DTTableTable;
DTTableTable.Dispose();
return catchConnectionTable;
}
答案 0 :(得分:3)
将Pooling = False添加到连接字符串
答案 1 :(得分:1)
你试过了吗?
using (MySqlConnection con = new MySqlConnection(ConfigurationManager.ConnectionStrings["mysqlCon"].ConnectionString))
{
con.open();
MySqlDataAdapter DataDTTables = new MySqlDataAdapter(MySQLCommandFunc)
DataDTTables.SelectCommand.CommandTimeout = 240000;
MySQLCommandFunc.Connection = con;
DataDTTables.Fill(DTTableTable);
con.close();
}
答案 2 :(得分:0)
Pooling=false
的替代方法是SqlConnection.ClearPool和SqlConnection.ClearAllPools方法。有关更多信息,请阅读:SQL Server Connection Pooling (ADO.NET)