2 回答

TA貢獻(xiàn)1772條經(jīng)驗(yàn) 獲得超5個(gè)贊
using (SqlConnection conn = new SqlConnection(DbHelperSQL.connectionString))
{
conn.Open();
SqlTransaction tran = conn.BeginTransaction();
SqlCommand cmd = new SqlCommand();
cmd.Transaction = tran;
cmd.Connection = conn;
try
{
//事務(wù)操作開始
string sql = string.Format("insert..")
cmd.CommandText = sql;
cmd.ExecuteNonQuery();
//事務(wù)操作結(jié)束
tran.Commit();
}
catch (Exception ex)
{
tran.Rollback();
throw ex;
}
finally
{
conn.Close();
}
}
sqlserver 事務(wù)的程序調(diào)用。是不是你要的???
- 2 回答
- 0 關(guān)注
- 481 瀏覽
添加回答
舉報(bào)