public void enqueue(object e)
{
try
{
DataChangeEventArgs e113 = (DataChangeEventArgs)e;
resetdatasource();
for (i=0; i < e113.sts.Length; i++)
{
int hour113 = e113.sts[i].TimeStampNet.Hour;
int minute113 = e113.sts[i].TimeStampNet.Minute;
int second113 = e113.sts[i].TimeStampNet.Second;
int millisecond113 = e113.sts[i].TimeStampNet.Millisecond;
int year113 = e113.sts[i].TimeStampNet.Year;
int month113 = e113.sts[i].TimeStampNet.Month;
int day113 = e113.sts[i].TimeStampNet.Day;
DateTime sdate113 = new DateTime(year113, month113, day113, hour113, minute113, second113, millisecond113);
DataRow row1 = dt.NewRow();
row1["itemID"] = e113.sts[i].HandleClient;
row1["paramvalue"] = convert.ToString(e113.sts[i].DataValue);
row1["date_logged1"] = sdate113.ToString("dd-MM-yyyy HH:mm:ss.fff");
row1["Quality"] = e113.sts[i].Quality;
row1["date_logged"] = DateTime.FromFileTime(e113.sts[i].TimeStamp);
dt.Rows.Add(row1);
}
var threadupdate = new Thread(update);
threadupdate.Start(dt);
}
catch { }
}
public void update(object dtnew)
{
try
{
MySqlConnection con = new MySqlConnection(LocalConnection.GetLocalConnetionStringmysql());
DataSet oldvalueds=new DataSet();
DataTable newupdateddata = new DataTable();
MySqlDataAdapter da;
MySqlTransaction trans;
if (con.State == ConnectionState.Closed)
con.Open();
trans = con.BeginTransaction();
da = new MySqlDataAdapter();
da.InsertCommand = new MySqlCommand("INSERT INTO parameter (itemID,paramvalue, date_logged1,Quality,date_logged) " +
"VALUES (@itemID, @paramvalue,@date_logged1,@Quality,@date_logged)" +
"ON DUPLICATE KEY UPDATE " +
"itemID=VALUES(itemID),paramvalue=VALUES(paramvalue),date_logged1=VALUES(date_logged1),Quality=VALUES(Quality),date_logged=VALUES(date_logged)", con);
da.InsertCommand.Parameters.Add("@itemID", MySqlDbType.VarChar, 250, "itemID");
da.InsertCommand.Parameters.Add("@paramvalue", MySqlDbType.VarChar, 250, "paramvalue");
da.InsertCommand.Parameters.Add("@date_logged1", MySqlDbType.VarChar, 250, "date_logged1");
da.InsertCommand.Parameters.Add("@Quality", MySqlDbType.VarChar, 250, "Quality");
da.InsertCommand.Parameters.Add("@date_logged", MySqlDbType.VarChar, 250, "date_logged");
da.InsertCommand.Transaction = trans;
DataTable newupdateddt = (DataTable)dtnew;
int k = da.Update(newupdateddt);
trans.Commit();
con.Close();
}
catch(Exception ex) {
}
finally
{
}
}
It will be thrown an exception like "Error connecting: Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached."
I will be set the timeout=200 in connection string this exception was thrown
"Deadlock found when trying to get lock; try restarting transaction"
Thanks in advance