请问下面这句为什么会报错: if ADOQryData.State in ([DB.dsInsert,DB.dsEdit]) then ADOQryData.UpdateBatch;--------------------------- Debugger Exception Notification --------------------------- Project l.exe raised exception class EDatabaseError with message 'ADOQryData: Dataset not in edit or insert mode'. Process stopped. Use Step or Run to continue. --------------------------- OK Help ---------------------------
procedure UpdateBatch(AffectRecords: TAffectRecords = arAll);
取消使用
procedure CancelBatch(AffectRecords: TAffectRecords = arAll);
需要设置
LockType := ltBatchOptimistic.
procedure UpdateBatch(AffectRecords: TAffectRecords = arAll);
取消使用
procedure CancelBatch(AffectRecords: TAffectRecords = arAll);
需要设置
LockType := ltBatchOptimistic
TADOQuery, TADOTable都有这个属性
给你代码看看:
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ADODB, DB;type
TForm1 = class(TForm)
ADOTable1: TADOTable;
ADOQuery1: TADOQuery;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
begin
ADOTable1.LockType := ltBatchOptimistic;
ADOTable1.UpdateBatch;
ADOQuery1.LockType := ltBatchOptimistic;
ADOQuery1.UpdateBatch; //像数据库保存的时候调用它。//本地保存调用postend;end.
我试了几次,还是不会用,调用updatebatch之前,对数据库的所有修改
应该是存在缓存中,那怎么显示在dbgrid中呢。怎么显示不了?
1.CursorType:keyset或static
2.locktype:batchoptimistic
3.SQL命令必须是select
4.cursorlocation为clUseClient
procedure UpdateBatch(AffectRecords: TAffectRecords = arAll);
procedure CancelBatch(AffectRecords: TAffectRecords = arAll);
ADOQryData.UpdateBatch;---------------------------
Debugger Exception Notification
---------------------------
Project l.exe raised exception class EDatabaseError with message 'ADOQryData: Dataset not in edit or insert mode'. Process stopped. Use Step or Run to continue.
---------------------------
OK Help
---------------------------