TClientDataSet提交之前用什么属性判断要提交的记录是新增进来的还是修改的呢?(50分)

  • 主题发起人 主题发起人 vmao
  • 开始时间 开始时间
V

vmao

Unregistered / Unconfirmed
GUEST, unregistred user!
TClientDataSet提交之前用什么属性判断要提交的记录是新增进来的还是修改的呢?
我要根据这个做不同的处理!status状态没有用!因为post以后状态就改变了,但实际上缓存还没有提交!
 
cds.StatusFilter:=[usInserted, usDeleted, usModified];
 
自己就可以判定的啊,实在要判定可以用UpdateStatus
 
if ClientDataSet.State = dsInsert then
begin
//进行插入后的处理
end;
if ClientDataSet.State = dsEdit then
begin
//进行修改后的处理
end;
 
if ClientDataSet.State = dsInsert then
begin
//进行插入后的处理
end;
if ClientDataSet.State = dsEdit then
begin
//进行修改后的处理
end;

这个是不行的!
althon64的可能有用!我下午测试一下结贴!
 
上面的全部错误:
TCustomClientDataSet.UpdateStatus
Reports the update status for the current record in the dataset.
function UpdateStatus: TUpdateStatus;
override;
Description
Call UpdateStatus to determine the update status for the current record in the client dataset. Update status can change frequently as records are edited, inserted, or deleted. UpdateStatus offers a convenient method for applications to assess the current status before undertaking or completing operations that depend on the update status of the current record.
Note: To determine whether there are updates pending for an entire dataset, check the ChangeCount property.

如下代码:

with cdsdo
begin
First;
while not eofdo
begin
case UpdateStatus of
usUnmodified :begin
end;

//The current record has no unapplied updates
usModified: begin
end;
//
The current record has unapplied modifications.
usInserted :begin
end;
//The current record has been inserted but the insertion was not applied.
usDeleted: begin
end;
//The current record represents a deleted record, where the deletion
has not yet been applied.
.


end;
end;
Next;

end;

 
多人接受答案了。
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
D
回复
0
查看
1K
DelphiTeacher的专栏
D
I
回复
0
查看
549
import
I
后退
顶部