我出1000分解决这个问题(另外开贴)--主从表删除后保存出错

prosectinfo 2003-08-19 11:25:14
有一主从表,CatchUpdate为True,都有主关键字

删除主表纪录前先删除从表对应的纪录

删除方法(应该不会有问题)
procedure DeleteItems;
begin
with tbDetail do
begin
DisableControls;
try
first;
While not eof do Delete;
finally
EnableControls;
end;
end;

保存方法
DataBase1.ApplyUpdates([tbmaster,tbDetails]);
保存时出错:Record/Key Deleted;
请问问什么?怎样改正!

分数一定给!
...全文
56 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
madyak 2003-08-19
  • 打赏
  • 举报
回复
procedure DeleteItems;
begin
with tbDetail do
begin
DisableControls;
try
first;
While not eof do
begin
Delete;
Next;//加上这句话
end;
finally
EnableControls;
end;
end;

保存方法
DataBase1.ApplyUpdates([tbmaster,tbDetails]);
lean77 2003-08-19
  • 打赏
  • 举报
回复
对呀,分我一点吧,就在帮助里面的!

The following example applies cached updates from a master/detail relationship. The updates are applied from the BeforeClose event handler of the detail set. Note that using cached updates in this manner requires that you apply updates any time you change the master record. For more control over cached updates, you must use a client dataset instead.

procedure TForm1.DetailBeforeClose(DataSet: TDataSet);
begin
if Master.UpdatesPending or Detail.UpdatesPending then
if Master.UpdateStatus = usInserted then
Database1.ApplyUpdates([Master, Detail])
else
Database1.ApplyUpdates([Detail, Master]);
end;
lean77 2003-08-19
  • 打赏
  • 举报
回复
对呀,分我一点,就在帮助里面!
The following example applies cached updates from a master/detail relationship. The updates are applied from the BeforeClose event handler of the detail set. Note that using cached updates in this manner requires that you apply updates any time you change the master record. For more control over cached updates, you must use a client dataset instead.

procedure TForm1.DetailBeforeClose(DataSet: TDataSet);
begin
if Master.UpdatesPending or Detail.UpdatesPending then
if Master.UpdateStatus = usInserted then
Database1.ApplyUpdates([Master, Detail])
else
Database1.ApplyUpdates([Detail, Master]);
end;
DWGZ 2003-08-19
  • 打赏
  • 举报
回复
procedure TForm1.DetailBeforeClose(DataSet: TDataSet);
begin
if Master.UpdatesPending or Detail.UpdatesPending then
if Master.UpdateStatus = usInserted then
Database1.ApplyUpdates([Master, Detail])
else
Database1.ApplyUpdates([Detail, Master]);
end;
DWGZ 2003-08-19
  • 打赏
  • 举报
回复
最基本的问题1000分? 楼上的分点给我吧
prosectinfo 2003-08-19
  • 打赏
  • 举报
回复
DataBase1.ApplyUpdates([tbDetails,tbmaster])
DataBase1.ApplyUpdates([tbmaster,tbDetails])
没有差别的.
lxpbuaa 2003-08-19
  • 打赏
  • 举报
回复
DataBase1.ApplyUpdates([tbDetails,tbmaster]);

————————————————————————————————————
宠辱不惊,看庭前花开花落,去留无意;毁誉由人,望天上云卷云舒,聚散任风。
————————————————————————————————————
DWGZ 2003-08-19
  • 打赏
  • 举报
回复
加上什么呀, 删除是先从后主, 如果还不行要缩小范围, 有更新从表看看如果还是报错那就是其它与它有关联的地方了
Spqk005 2003-08-19
  • 打赏
  • 举报
回复
财主
仔细看看别的小地方
应该可以找出的
prosectinfo 2003-08-19
  • 打赏
  • 举报
回复
to : DWGZ,lean
我加上后还是不行啊

5,386

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧