Private void button#click (Object sender, eventargs E)
{
// Display the transaction
Sqltransaction Tran;
String sconn = "Server =. \ Ds; database = t105_2005; uid = sa; Pwd = Sasa ";
String sql1 = "Update ZH set ZM = ZM-" + convert. todouble (this. textbox1.text. Trim () + "where Zid = '000000 '";
String sql2 = "Update ZH set ZM = ZM +" + convert. todouble (this. textbox1.text. Trim () + "where Zid = '000000 '";
Sqlconnection con = new sqlconnection (sconn );
Con. open ();
TRAN = con. begintransaction ();
Sqlcommand COM = new sqlcommand ();
Try
{
Com. Connection = con;
Com. Transaction = Tran;
Com. commandtext = sql1;
Com. executenonquery ();
Com. commandtext = sql2;
Com. executenonquery ();
Con. Close ();
MessageBox. Show ("account loaded successfully ");
Tran. Commit ();
}
Catch
{
MessageBox. Show ("account loading failed ");
Tran. rollback ();
}
}
}