CSDN博客

img ycl111

使用事务

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

   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