Quantcast
Channel: ADO.NET, Entity Framework, LINQ to SQL, NHibernate
Viewing all articles
Browse latest Browse all 1698

ADO.NET & MySQL - max_user_connections

$
0
0

Hi everyone,

I have an issue with a legacy web-forms application that uses ADO.NET and MySQL.

Quite often I get the error of 'max_user_connections' and talking through the issue with my web host, it appears that my code is not killing off idle connections somewhere.

Here is my connection code, does anything stand out as obvious that could be causing this issue?

public class MySQL
{
	private static string connectionString = ConfigurationManager.ConnectionStrings["MySQLConnectionInfo"].ConnectionString;

	public class Get
	{
		public static DataTable GetDataTableUsingParms(string inSQL, List<dbParm> inParms, string from = null)
		{
			try
			{
				using (MySqlConnection myConnection = new MySqlConnection(connectionString))
				{
					using (MySqlCommand myCommand = new MySqlCommand(inSQL, myConnection))
					{
						foreach (dbParm inParm in inParms)
						{
							MySqlParameter currentParm = new MySqlParameter();

							currentParm.ParameterName = inParm.ParmName;
							currentParm.Value = inParm.ParmValue;

							myCommand.Parameters.Add(currentParm);
						}

							DataTable myDataTable = new DataTable();
							using (MySqlDataAdapter myAdapter = new MySqlDataAdapter(myCommand)) {
							myAdapter.Fill(myDataTable);
						}

						return myDataTable;
					}
				}
			}
			catch (MySql.Data.MySqlClient.MySqlException err)
			{
				throw new System.Exception(err.ToString());
			}
			catch (System.TimeoutException err)
			{
				throw new System.Exception(err.ToString());
			}
			catch (System.Exception err)
			{
				throw new System.Exception(err.ToString());
			}
		}
	}
}

I'm allowed 30 connections on my web-host (this is controlled at package level so can't be changed) and this issue happens with very few users (< 10) on the site.

Thank you


Viewing all articles
Browse latest Browse all 1698

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>