ado。net的事物BeginTransaction demo

var seqNoList = seqNos.SplitToList(",");            

var db = CreateDb();            

List<DBParameter> paraList = new List<DBParameter>();            

DBParameter para = null;             string strSql = string.Empty;

            try             {                 db.BeginTransaction();

                for (int i = 0; i < seqNoList.Count; i++)                 {                     strSql = "delete from Item_tBasicInfo where SeqNo = @SeqNo";

                    paraList = new List<DBParameter>();                     para = new DBParameter("SeqNo", DbDataType.Int64);                     para.Value = seqNoList[i].ToInt64();                     paraList.Add(para);

                    db.ExecuteNonQuery(strSql, paraList);                 }

                db.Commit();                 return true;             }             catch             {                 db.Rollback();                 throw;             }

你可能感兴趣的:(transaction)