dephi通过什么方式连接的数据库?需要把隐式事务打开(非自动提交模式)

解决方案 »

  1.   

    使用TDatabase控件
      query1.databasename :=database1.databasename;  with Query1 do
      begin
        try
          Database1.StartTransaction;
          if active then close;
          sql.text := 'select * from 表1 where rkey=1 for update nowait';
          ExecSQL;
          {do some other sql you want;}
          Database1.Commit; {on success, commit the changes};
        Except
          Database1.Rollback; {on failure, undo the changes};
          ShowMessage('该记录被另一用户锁定!' );
          Exit;
      End;