日期:2014-05-18 浏览次数:20927 次
List<string> sqlList= new List<string>();
sqlList.Add("update pictures set remark='testb' where infouuid='test'");
sqlList.Add("update pictures set remarkf='testb' where infouuid='test0'");
sqlList.Add("update pictures set remark='testb' where infouuid='test2'");
using (DbConnection connection = GetConnection())
{
connection.Open();
DbTransaction transaction = connection.BeginTransaction();
DbCommand cmd = connection.CreateCommand();
cmd.Transaction = transaction;
foreach (string strSql in sqlList)
{
if (!string.IsNullOrEmpty(strSql))
{
cmd.CommandText = strSql;
cmd.ExecuteNonQuery();
}
}
transaction.Commit();
}