关于事务
征服者X 2009-04-03 12:43:05 今天早网上找了一段关于事务的代码,下面红色部分是有问题的部门。需要加什么命名空间或什么的忘大家多多指导
private void but_Ok_Click(object sender, EventArgs e)
{
CommittableTransaction tx = new CommittableTransaction();
Utilities.DisplayTransactionInformation("TX created", tx.TransactionInformation);
try
{
Student s1 = new Student();
s1.FirstName = ""+this.textBox1.Text.Trim()+"";
s1.Lastname = "" + this.textBox2.Text.Trim() + "";
s1.Company = "" + this.textBox3.Text.Trim() + "";
StudentDatadb db = new StudentDatadb();
db.AddStudent(s1, tx);
if (Utilities.AbortTx())
{
throw new ApplicationException("transaction abort");
}
tx.Commit();
}
catch (System.Exception ex)
{
MessageBox.Show(ex.Message);
tx.Rollback();
}
Utilies.DisplayTransactionInformation(tx.TransactionInformation);
}