CSDN博客

img ycl111

使用事务

发表于2004/12/31 11:22:00  954人阅读

   using (SqlConnection conn = new SqlConnection(SQLHelper.CONN_STRING_NON_DTC)) {
    conn.Open();
    using (SqlTransaction trans = conn.BeginTransaction()) {
     try {
      SQLHelper.ExecuteNonQuery(trans, CommandType.Text, SQL_INSERT_SIGNON, signOnParms);
      SQLHelper.ExecuteNonQuery(trans, CommandType.Text, SQL_INSERT_ACCOUNT, accountParms);
      SQLHelper.ExecuteNonQuery(trans, CommandType.Text, SQL_INSERT_PROFILE, profileParms);
      trans.Commit();
     
     }catch {
      trans.Rollback();
      throw;
     }
    }
   }
0 0

相关博文

我的热门文章

img
取 消
img即使是一小步
也想与你分享
打开
img