一
一灯
Unregistered / Unconfirmed
GUEST, unregistred user!
我建立了一个Access2000数据库,库中有两的表,表1和表2,表1实际是一套题库,表2是试题
表2的“题目编号”是表1的编号。两者相联。在我清空表2时出现了问题。代码如下:
procedure TDataModule2.EmptyTemp;
var OriginTable:string;
i:integer;
linked:Boolean;
begin
OriginTable:=ADOTable2.TableName;
ADOTable2.TableName:='表2';
if ADOTable2.RecordCount<1 then
begin
ADOTable2.TableName:=OriginTable;
exit;
end;
if ADOTable1.MasterSource=nil then
Linked:=false
else
linked:=true;
unlink;
for i:=ADOTable2.RecordCount downto 1 do
begin
ADOTable2.RecNo:=i;
{*} ADOTable2.Delete;
end;
ADOTable2.TableName:=OriginTable;
if Linked then Link;
end;
procedure TDataModule2.Link;
begin
ADOTable1.MasterSource:=DataSource2;
ADOTable1.MasterFields:='题目编号';
end;
procedure TDataModule2.Unlink;
begin
ADOTable1.MasterSource:=nil;
ADOTable1.MasterFields:='';
end;
在执行到{*}时,出现异常“Key Column infomation is insufficent or incorrect,too many
rows were affected by update.”这是什么原因。
清空表2为什么不能用deleterecords()
表2的“题目编号”是表1的编号。两者相联。在我清空表2时出现了问题。代码如下:
procedure TDataModule2.EmptyTemp;
var OriginTable:string;
i:integer;
linked:Boolean;
begin
OriginTable:=ADOTable2.TableName;
ADOTable2.TableName:='表2';
if ADOTable2.RecordCount<1 then
begin
ADOTable2.TableName:=OriginTable;
exit;
end;
if ADOTable1.MasterSource=nil then
Linked:=false
else
linked:=true;
unlink;
for i:=ADOTable2.RecordCount downto 1 do
begin
ADOTable2.RecNo:=i;
{*} ADOTable2.Delete;
end;
ADOTable2.TableName:=OriginTable;
if Linked then Link;
end;
procedure TDataModule2.Link;
begin
ADOTable1.MasterSource:=DataSource2;
ADOTable1.MasterFields:='题目编号';
end;
procedure TDataModule2.Unlink;
begin
ADOTable1.MasterSource:=nil;
ADOTable1.MasterFields:='';
end;
在执行到{*}时,出现异常“Key Column infomation is insufficent or incorrect,too many
rows were affected by update.”这是什么原因。
清空表2为什么不能用deleterecords()