事务处理(二)(System.Transactions)
时间:2010-10-27 来源:不信算了
1 protected void Page_Load(object sender, EventArgs e)
2 {
3 try
4 {
5 Transaction.BeginTransaction(DataBase.MsSQL);
6
7 Bll.UserBll ub = new Bll.UserBll();
8
9 Model.User user = new Model.User();
10
11 user.Name = "不信算了";
12
13 ub.InserUser(user);
14
15 Model.Order od = new Model.Order();
16
17 od.UserID =int.Parse(name.Text);
18 od.Orderitem = "黄瓜";
19
20 ub.InserOrder(od);
21
22 Transaction.Commit(DataBase.MsSQL);
23
24 }catch(Exception ex)
25 {
26 Transaction.Rollback(DataBase.MsSQL);
27 }
28 }
相关阅读 更多 +