MySQL Tutorial too many connections
Solution:
1. Join try/catch/finally where you use MySQL data source
2. Check whether the mysqlconnection after use to do close ()
3. Do not make the mysqlconnection connection static, each connection creates a new connection
eg
Copy content to Clipboard program code
MySql.Data.MySqlClient.MySqlConnection mysqlconnection = new Mysqlconnection (sds.sms. DAL. SQLHELPER.STRSMS);
Mysqlconnection.open ();
String SelectCommand = "Select Id,model,number,brand,sendtime,pubdate,autoinsert_flag,mobilephone from Tbl_saledata where autoinsert_flag=0 and sendtime= ' "+ Date +" ' ";
Try
{
IList ilst = new List ();
using ( Mysqldatareader dr = MySql.Data.MySqlClient.MySqlHelper.ExecuteReader (sds.sms. DAL. Sqlhelper.strsms, SelectCommand)
{
while (Dr. Read ())
{
Ilst.add (Populater (DR));
}
return ilst;
Shut down
Dr. Close ();
Mysqlconnection.close ();
}
}
catch (Exception e)
{
Throw e;
}
Finally
{
Mysqlconnection.close ();
}