关于Delphi7的CacheUpdate

Kevin_Lmx 2004-09-20 09:28:28
以前用D5的时候是这样写的:
Query1.Post;
Database.StartTransaction;
Database.ApplyUpdates;
Database.CommitUpdates;

而到了D7下,这样写却出错:
Query1.Post;
Database.StartTransaction;
Database.ApplyUpdates([]);
Datebase.Commit;

出错信息为: A user Transaction is Already in Progress.
我试过去掉这一句:Database.ApplyUpdates([]);
不会出错,但是提交不了。谁帮忙解决一下?谢谢!!
...全文
131 7 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
sam811112 2004-09-25
  • 打赏
  • 举报
回复
Query1.Post;
DM.dbCrm.ApplyUpdates([Query1]);
DM.dbCrm.StartTransaction;
DM.dbCrm.Commit;
Kevin_Lmx 2004-09-21
  • 打赏
  • 举报
回复
在下已经自己解决了.应该这样写:
Query1.Post;
Database.ApplyUpdates([Query1]);
Database.StartTransaction;
Datebase.Commit;
ghchen 2004-09-21
  • 打赏
  • 举报
回复
Database.ApplyUpdates(0);
Jumpi 2004-09-21
  • 打赏
  • 举报
回复
看看Delphi7的帮助文件吧:它会自动开始一个事务

Applying updates is a two-phase process that takes place within the context of the database component’s transaction control. When an application calls ApplyUpdates, the following events take place:

1 A database transaction starts.(**********************)
2 Cached updates are written to the database (Phase 1).

If the database write is successful:

1 Database changes are committed, ending the transaction.
2 Cached updates are committed, clearing the internal cache buffer (Phase 2).

If the database write fails database changes are rolled back, ending the transaction.

The two-phased approach allows for effective error recovery, especially when updating multiple and interrelated datasets (for example, the datasets associated with a master/detail form).
viaboy 2004-09-21
  • 打赏
  • 举报
回复
Database.ApplyUpdates(0);
dext 2004-09-20
  • 打赏
  • 举报
回复
Database.ApplyUpdates(0);
sam811112 2004-09-20
  • 打赏
  • 举报
回复
up
up
up
up
up
up
up
up
up
up
up
up
up
up
up
up
up
up
up
up
up
up
up
up
up
up
up
up
up
up
up
up
up
up
up
up
up
up
up
up
up
up
up
up
up
up
up
up
up
up
up
up

2,507

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 数据库相关
社区管理员
  • 数据库相关社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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