TAdoquery问题设置成批处理后, 怎样找出哪些些是编辑过的, 哪些是没有编辑过的记录 ( 积分: 50 )

  • 主题发起人 主题发起人 ywk1979
  • 开始时间 开始时间
Y

ywk1979

Unregistered / Unconfirmed
GUEST, unregistred user!
TAdoquery问题设置成批处理后, 怎样找出哪些些是编辑过的, 哪些是没有编辑过的记录
 
TAdoquery问题设置成批处理后, 怎样找出哪些些是编辑过的, 哪些是没有编辑过的记录
 
参考如下帖子,除了不能读取删除的外,其他的都可以

http://www.delphibbs.com/delphibbs/dispq.asp?LID=3175459
 
为什么没人回答呀
 
晕,我上面贴的就是专门针对这个问题的,麻烦用鼠标点一下好吗
 
是的,上面已经帖出地址了,你如果和这个要求一样需要连删除的一起读出来那么也请留下mail。如果仅仅是修改、添加的记录那么这个帖子已经可以给你答案了。仔细看看吧,不要偷懒!
 
to hongxing_dl大虾

不能把代码直接贴出来吗?你都说了好多次了,我给分
 
关注一下,再蒙一下!:) 能否复制AdoQuery.recordset,然后cancelbatch,再比较一下,不知行不
 
给个地方我传上去吧,贴出来真怕各位看不懂啊,没别的意思 ̄ ̄
adoquery删除的记录为一空记录,所以取不到值,而cds就可以。
 
传上到哪里又不一样?代码很长吗?就传到盒子去呗?短的话,直接贴算了,你老兄的日记我也记了不少呢
 
那就这里了,各位没看懂可不能怪我呀 :)
其实关键的还是在dfm里

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, Grids, DBGrids, DB, ADODB, Provider, DBClient;

type
TForm1 = class(TForm)
ADOConnection1: TADOConnection;
ADOTable1: TADOTable;
DataSource1: TDataSource;
DBGrid1: TDBGrid;
ClientDataSet1: TClientDataSet;
DataSetProvider1: TDataSetProvider;
BitBtn3: TBitBtn;
Memo1: TMemo;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
BitBtn4: TBitBtn;
BitBtn5: TBitBtn;
Label1: TLabel;
procedure BitBtn3Click(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
procedure BitBtn4Click(Sender: TObject);
procedure BitBtn5Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}
//显示
procedure TForm1.BitBtn3Click(Sender: TObject);
begin
memo1.lines.clear;
with clientdataset1 do
begin
////////////////////
StatusFilter := [usModified, usInserted, usDeleted];
Filtered := True;
while not eof do
begin
case UpdateStatus of
usModified : Memo1.Lines.Add('修改: '+vartostr(fields[1].oldvalue)+' => '+fields[1].asstring);
usInserted : Memo1.Lines.Add('新增: '+fields[1].asstring);
usDeleted : Memo1.Lines.Add('删除: '+vartostr(fields[1].oldvalue));
end;
next;
end;
StatusFilter := [];
end;
end;
//将修改过的记录过滤出来
procedure TForm1.BitBtn1Click(Sender: TObject);
begin
clientdataset1.StatusFilter := [usModified, usInserted, usDeleted];
clientdataset1.Filtered := True;
end;
//取消过滤
procedure TForm1.BitBtn2Click(Sender: TObject);
begin
clientdataset1.StatusFilter := [];
end;
//取消修改
procedure TForm1.BitBtn4Click(Sender: TObject);
begin
clientdataset1.cancelupdates
end;
//提交修改
procedure TForm1.BitBtn5Click(Sender: TObject);
begin
clientdataset1.applyupdates(-1);
end;

dfm内容:
object Form1: TForm1
Left = 192
Top = 133
Width = 622
Height = 480
Caption = 'Form1'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
OnCreate = FormCreate
PixelsPerInch = 96
TextHeight = 13
object Label1: TLabel
Left = 8
Top = 352
Width = 342
Height = 13
Caption = '设置过滤后就是过滤出已经修改的记录(包括新增,修改,删除)。'
end
object DBGrid1: TDBGrid
Left = 8
Top = 8
Width = 337
Height = 297
DataSource = DataSource1
TabOrder = 0
TitleFont.Charset = DEFAULT_CHARSET
TitleFont.Color = clWindowText
TitleFont.Height = -11
TitleFont.Name = 'MS Sans Serif'
TitleFont.Style = []
end
object BitBtn3: TBitBtn
Left = 352
Top = 312
Width = 75
Height = 25
Caption = '显示状态'
TabOrder = 1
OnClick = BitBtn3Click
end
object Memo1: TMemo
Left = 352
Top = 8
Width = 249
Height = 297
TabOrder = 2
end
object BitBtn1: TBitBtn
Left = 8
Top = 312
Width = 75
Height = 25
Caption = '过滤'
TabOrder = 3
OnClick = BitBtn1Click
end
object BitBtn2: TBitBtn
Left = 96
Top = 312
Width = 75
Height = 25
Caption = '取消过滤'
TabOrder = 4
OnClick = BitBtn2Click
end
object BitBtn4: TBitBtn
Left = 176
Top = 312
Width = 75
Height = 25
Caption = '取消修改'
TabOrder = 5
OnClick = BitBtn4Click
end
object BitBtn5: TBitBtn
Left = 256
Top = 312
Width = 75
Height = 25
Caption = '提交修改'
TabOrder = 6
OnClick = BitBtn5Click
end
object ADOConnection1: TADOConnection
Connected = True
ConnectionString =
'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:/Documents and Se' +
'ttings/zj.ZHOUJUN/桌面/TEST/记录状态/db1.mdb;Persist Security Info=Fal' +
'se'
LoginPrompt = False
Mode = cmShareDenyNone
Provider = 'Microsoft.Jet.OLEDB.4.0'
Left = 104
Top = 112
end
object ADOTable1: TADOTable
Connection = ADOConnection1
CursorType = ctStatic
TableName = '表1'
Left = 120
Top = 192
end
//////////////////////////////////////就这下面的关键了
object DataSource1: TDataSource
DataSet = ClientDataSet1
Left = 216
Top = 120
end
object ClientDataSet1: TClientDataSet
Active = True
Aggregates = <>
Params = <>
ProviderName = 'DataSetProvider1'
Left = 128
Top = 160
end
object DataSetProvider1: TDataSetProvider
DataSet = ADOTable1
Left = 232
Top = 264
end
end
 
不错,不知道为什么ADOQuery 不行,帮助里面居然还工工整整的写了个读取的例子

adoquery删除的记录为一空记录,所以取不到值
这句话怎么理解,大虾指教
 
不会是adoquery故意装怪吧:)
我调试过,在adoquery里删除的记录,都是以空记录显示的,不明白其中奥妙。
 

Similar threads

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