//事务
using (SqlTransaction sqlTran = sqlgen.BeginTransaction)
{
try
{
sqlgen.ExecuteNonQuery(sqlTran, "sql语句1");
sqlgen.ExecuteNonQuery(sqlTran, "sql语句2");
sqlTran.Commit();
}
catch
{
sqlTran.Rollback();
}
}
#region BeginTransaction 开始一个事务
/// <summary>
/// 开始一个事务
/// </summary>
/// <returns>事务</returns>
public SqlTransaction BeginTransaction()
{
SqlConnection c = new SqlConnection(conn);
c.Open();
return c.BeginTransaction();
}
#endregion
using (SqlTransaction sqlTran = sqlgen.BeginTransaction)
{
try
{
sqlgen.ExecuteNonQuery(sqlTran, "sql语句1");
sqlgen.ExecuteNonQuery(sqlTran, "sql语句2");
sqlTran.Commit();
}
catch
{
sqlTran.Rollback();
}
}
#region BeginTransaction 开始一个事务
/// <summary>
/// 开始一个事务
/// </summary>
/// <returns>事务</returns>
public SqlTransaction BeginTransaction()
{
SqlConnection c = new SqlConnection(conn);
c.Open();
return c.BeginTransaction();
}
#endregion