Delphi实现数据库中一个记录在两张表中增加与删除的同步,比如说转账,你的卡上的钱会被减少而对方卡上会同时相应增加相应的钱,这个功能代码如可实现啊

解决方案 »

  1.   

    存储过程吧,或者用事务,2个sql语句
      

  2.   

    肯定是用事务来处理的
    //开始事务
    adoconnection1.BeginTrans;
    try
      //减少表数
      //增加另一个表的信息
      //提交
      adoconnection1.CommitTrans;
    except
      //出错回滚事务
      adoconnection1.RollbackTrans;
    end;  
      
      
      

  3.   

    用事务 处理.   对于你的需求 还不是很明确  
    if ADOConnection1.InTransaction then
      ADOConnection1.RollbackTrans;
    ADOConnection1.BeginTrans;
    // 处理你需要的 事件
    try
      ADOConnection1.CommitTrans;
    except
      ADOConnection1.RollbackTrans;
    end;
      

  4.   

    在存储过程中用事务
    create procedure USERPROC_NAMEasbegin tran 
     if @@error<>0 or @@rowcount=0
     begin
        rollback tran
        return
     endcommit tran