newtomysql
Technical User
Dear All,
I got a list of product where based on a datareader I run a for loop. The based on each of the productID i do a number of select statement from various table around 24 different types of selects. So at some times my code give me an error saying that "unable to connect to any of the specified mysql hosts. So below is how my connection query looks like. I have tried to change to pooling=true the effect is quite the same. The error comes on a random basis sometimes during runing the 13th statement or 17th statement etc. So any solution for this type of multiples queries? I have 2 separate connection query one for the outler loop and one inner loop for each of the select statement once done I close and open the connection. Thanks.
public globalConnectionLocal2()
{
this.connection1 = new MySqlConnection("Address='localhost';Database='db1';User Name='root';Password='12345';Pooling='false'");
this.command = this.connection1.CreateCommand();
this.connection1.Open();
}
// destructor - explicitly
~globalConnectionLocal2()
{
this.command.Dispose();
this.connection1.Close();
this.connection1.Dispose();
}
I got a list of product where based on a datareader I run a for loop. The based on each of the productID i do a number of select statement from various table around 24 different types of selects. So at some times my code give me an error saying that "unable to connect to any of the specified mysql hosts. So below is how my connection query looks like. I have tried to change to pooling=true the effect is quite the same. The error comes on a random basis sometimes during runing the 13th statement or 17th statement etc. So any solution for this type of multiples queries? I have 2 separate connection query one for the outler loop and one inner loop for each of the select statement once done I close and open the connection. Thanks.
public globalConnectionLocal2()
{
this.connection1 = new MySqlConnection("Address='localhost';Database='db1';User Name='root';Password='12345';Pooling='false'");
this.command = this.connection1.CreateCommand();
this.connection1.Open();
}
// destructor - explicitly
~globalConnectionLocal2()
{
this.command.Dispose();
this.connection1.Close();
this.connection1.Dispose();
}