//G1.conn1 returns a new instance of a connection to the database.
private void btnLock_Click(object sender, System.EventArgs e)
{
MySqlCommand cmd = new MySqlCommand("Lock Table TestTable write, TestTable as t1 write", G1.conn1);
G1.TryNonQueryStatic(cmd);
}
private void btnUnlock_Click(object sender, System.EventArgs e)
{
MySqlCommand cmd = new MySqlCommand("Unlock Tables",G1.conn1);
G1.TryNonQueryStatic(cmd);
}
private void btnWrite_Click(object sender, System.EventArgs e)
{
Double dd;
if((txtWrite.Text.Length > 0)&&(Double.TryParse(txtWrite.Text,System.Globalization.NumberStyles.Number,null,out dd)))
{
MySqlCommand cmd = new MySqlCommand("Update testtable as t1 set testdouble = " + Double.Parse(txtWrite.Text).ToString(),G1.conn1);
int affected = G1.TryNonQueryStatic(cmd);
MessageBox.Show("Affected = " + affected.ToString());
}
else
MessageBox.Show("Textbox value is invalid");
}
private void btnRead_Click(object sender, System.EventArgs e)
{
MySqlCommand cmd = new MySqlCommand("Select testdouble from testtable",G1.conn1);
lblRead.Text = G1.TryScalarStatic(cmd);
}
|