MySQL连接不会关闭 [英] MySQL Connection will not close

查看:120
本文介绍了MySQL连接不会关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这真的很简单,我要做的就是填充一个数据表,我所有的东西都被using()包围了,并且该连接不会进行处理/关闭.请帮助

This is really simple, all i'm trying to do is fill a datatable, i have everything surrounded by using() and the connection will not dispose/close. Please help

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

Add Pooling=False to the connection string

这篇关于MySQL连接不会关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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