I'm not sure what the reason for the error I'm having is but it looks like it's something about the open connections in the database, where an error is occurring if the application tries to create more connections than the limit. I think this is the reason for the error.
I'm closing every Connection I open for an interaction (insert / update / delete / select).
I've read some topics on Stack Overflow, but none of those based on C # has solved this problem.
Here is the connection code for my db
and an interaction as an example:
Connection Class:
public class ClassConexao
{
public static MySqlConnection ObterConexao()
{
MySqlConnection conectar = new MySqlConnection("server=ENDEREÇO; database=NOME; Uid=USER; pwd=****");
conectar.Open();
return conectar;
}
}
Interaction:
try
{ //ABRINDO CONEXAO01
MySqlConnection conexão01= ClassConexao.ObterConexao();
MySqlCommand _comandoSel = new MySqlCommand(String.Format("SELECT Column1, Column2 FROM tableA WHERE Column1 = " + "500" + ""), conexão01);
MySqlDataReader 01_reader = _comando01.ExecuteReader();
Sel_reader.Read();
textbox1.Text = 01_reader.GetString(0);
textbox2.Text = 01_reader.GetString(1);
//FECHANDO CONEXAO01
conexão01.Close();
catch (Exception error)
{
MessageBox.Show(String.Format("Algo está errado com a operação! {0}", error.Message));
return;
}
Error message returned:
Is there any way to increase this limit? Or another solution that does not limit the connections?