I have some functions that connect to the database. For example : function with adds a new user after registration :
public void AddUser(UserModel user)
{
using (MySqlConnection connection = new MySqlConnection(this.ConnectionString))
{
connection.Open();
MySqlCommand cmd = connection.CreateCommand();
cmd.CommandText = "insert into users (login , password , email ) values (@name , @password , @email)";
cmd.Parameters.AddWithValue("@name", user.Name);
cmd.Parameters.AddWithValue("@password", user.Password);
cmd.Parameters.AddWithValue("@email", user.Email);
cmd.ExecuteNonQuery();
connection.Close();
}
}
I have more similar functions that invoke almost at the same time. When i run application I have a MySqlException : "Too many connections". I set max_connections to 100000 in my database and i set Pooling=false in connection string but it doesn't change anything.