匪
匪匪
Unregistered / Unconfirmed
GUEST, unregistred user!
我按照李维《分布式多层系统篇》中第5章无状态例子做的程序为什么有错。
代码如下所示:
var
。。。。
VOwnerData1levariant;
implementation
uses 。。。。;
function Tform_khzl.GetKeyField(Sender:TObject): OleVariant;
var
temp_bookmark:TBookmark;
begin
with dm_customer1do
begin
temp_bookmark:=ClientDataset1.GetBookmark;
ClientDataset1.Last;
result:=ClientDataset1.fieldbyname('编号').Value;////////////////////
ClientDataset1.GotoBookmark(temp_bookmark);
ClientDataset1.FreeBookmark(temp_bookmark);
end;
end;
程序执行完Clientdataset1.Laset后出错,Clientdataset1:can't perform this operation on this closed dataset.
我的其它代码都是按照他书上写的。
More按钮(显示下一段数据)代码:
procedure Tform_khzl.SpeedButton2Click(Sender: TObject);
var
temp_bookmark:TBookmark;
bTrueEof:Boolean;
begin
//main.form_main.WS_customer.Edit(Edit1.Text,Edit2.Text,Edit3.Text,Edit4.Text,Edit5.Text,Edit6.Text,Edit7.Text);
bTrueEof:=false;
with dm_customer1do
if (not bTrueEof) then
begin
temp_bookmark:=Clientdataset1.getbookmark;
if Clientdataset1.GetNextPacket<Clientdataset1.PacketRecords then
bTrueEof:=true;
ClientDataset1.Last;
VOwnerData1:=Clientdataset1.FieldByName('编号').Value;
ClientDataset1.GotoBookmark(temp_bookmark);
ClientDataset1.Next;
ClientDataset1.FreeBookmark(temp_bookmark);
end;
end;
procedure TDM_customer1.ClientDataSet1BeforeGetRecords(Sender: TObject;
var OwnerData: OleVariant);
begin
if (VarisEmpty(VOwnerData1)) or (VarisNull(VOwnerData1)) then
OwnerData:=form_khzl.GetKeyField(Sender);
OwnerData:=VOwnerData1;
end;
其它程序都没有错,就是在GetKeyField中有错
代码如下所示:
var
。。。。
VOwnerData1levariant;
implementation
uses 。。。。;
function Tform_khzl.GetKeyField(Sender:TObject): OleVariant;
var
temp_bookmark:TBookmark;
begin
with dm_customer1do
begin
temp_bookmark:=ClientDataset1.GetBookmark;
ClientDataset1.Last;
result:=ClientDataset1.fieldbyname('编号').Value;////////////////////
ClientDataset1.GotoBookmark(temp_bookmark);
ClientDataset1.FreeBookmark(temp_bookmark);
end;
end;
程序执行完Clientdataset1.Laset后出错,Clientdataset1:can't perform this operation on this closed dataset.
我的其它代码都是按照他书上写的。
More按钮(显示下一段数据)代码:
procedure Tform_khzl.SpeedButton2Click(Sender: TObject);
var
temp_bookmark:TBookmark;
bTrueEof:Boolean;
begin
//main.form_main.WS_customer.Edit(Edit1.Text,Edit2.Text,Edit3.Text,Edit4.Text,Edit5.Text,Edit6.Text,Edit7.Text);
bTrueEof:=false;
with dm_customer1do
if (not bTrueEof) then
begin
temp_bookmark:=Clientdataset1.getbookmark;
if Clientdataset1.GetNextPacket<Clientdataset1.PacketRecords then
bTrueEof:=true;
ClientDataset1.Last;
VOwnerData1:=Clientdataset1.FieldByName('编号').Value;
ClientDataset1.GotoBookmark(temp_bookmark);
ClientDataset1.Next;
ClientDataset1.FreeBookmark(temp_bookmark);
end;
end;
procedure TDM_customer1.ClientDataSet1BeforeGetRecords(Sender: TObject;
var OwnerData: OleVariant);
begin
if (VarisEmpty(VOwnerData1)) or (VarisNull(VOwnerData1)) then
OwnerData:=form_khzl.GetKeyField(Sender);
OwnerData:=VOwnerData1;
end;
其它程序都没有错,就是在GetKeyField中有错