List<string> sqllist = new List<string>();
string grade_sqlCmd =””;
sqllist.Add(grade_sqlCmd);
using (SqlConnection connection = new SqlConnection(SQLHelper.NukeDBConnectionString))
{
connection.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = connection;
SqlTransaction tx = connection.BeginTransaction();
cmd.Transaction = tx;
try
{
for (int n = 0; n < sqllist.Count; n++)
{
string strsql = sqllist[n];
if (strsql.Trim().Length > 1)
{
cmd.CommandText = strsql;
cmd.ExecuteNonQuery();
}
}
tx.Commit();//执行事务
return new ExecResultData(true);
}
catch
{
tx.Rollback(); //回滚事务
return new ExecResultData(“执行失败”);
}
finally
{
cmd.Dispose();
connection.Close();
}
}