我想在2个单独的表上进行插入和更新,但是将它们放在1个事务中).
基本上在伪代码中我想做类似的事情:
MysqLTransaction trans = null; try { _Connection.Open(); trans = _Connection.BeginTransaction(); insertCmd.Transaction = trans; updateCmd.Transaction = trans; Int32 id = insertCmd.ExecuteNonQuery(); updateCmd.Parameters.Add(new MysqLParameter("oid",MysqLDbType.Int32).Value = id); updateCmd.ExecuteNonQuery(); } catch(MysqLException) { if(trans != null) trans.RollBack(); } finally { _Connection.Close(); }