gpt4 book ai didi

c# - MySQL连接不会关闭

转载 作者:行者123 更新时间:2023-11-29 01:44:09 25 4
gpt4 key购买 nike

这真的很简单,我要做的就是填充一个数据表,我将所有内容都用 using() 包围起来,并且连接不会处理/关闭。请帮忙

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;
}

最佳答案

在连接字符串中添加 Pooling=False

关于c# - MySQL连接不会关闭,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11472768/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com