用query查询出的记录,修改后一结束查询发现没改过,cache中的数据不提交怎么办?
用了tquery,tupdatasql,query的requestlive:=true updateobjext:=updatesql1
cachedupdates:=true,但就是不能更改,改过后结束查询就不变动原记录。疑是cache中的数据没写入库中。在论坛上找了一帖子,在query的afterpost中写query1.applyupdates[query1];结果编译时说什么重复了,不通。请问应该是如何写?
顺便再问一下,updatesql中有几个关于插入,删除记录的属性,那里的sql是怎么写的?比如我要删除当前查出的记录。
问题点数:35、回复次数:13Top
1 楼chenjiong(准程序员:升级中....)回复于 2001-04-10 10:06:00 得分 0
query1.applyupdates[query1];这一句错在哪Top
2 楼yukuang(编程是我的业余爱好)回复于 2001-04-10 10:22:00 得分 0
query1.applyupdatesTop
3 楼chenjiong(准程序员:升级中....)回复于 2001-04-10 10:44:00 得分 0
我原先已经用过了,也是没有变化的。Top
4 楼coldljy(青山隐隐)回复于 2001-04-10 10:49:00 得分 0
HELP中写道:
Call ApplyUpdates to write a dataset pending cached updates to a database. This method passes cached data to the database for storage, but the changes are not committed to the database. An application must explicitly call the database component抯 Commit method to commit the changes to the database if the write is successful, or call the database Rollback method to undo the changes if there is an error.
e.g.
he following procedure illustrates how to apply a dataset cached updates to a database in response to a button click:
procedure TForm1.ApplyButtonClick(Sender: TObject);
begin
with CustomerQuery do
begin
Database1.StartTransaction;
try
ApplyUpdates; {try to write the updates to the database};
Database1.Commit; {on success, commit the changes};
except
Database1.Rollback; {on failure, undo the changes};
raise; {raise the exception to prevent a call to CommitUpdates!}
end;
CommitUpdates; {on success, clear the cache}
end;
end;Top
5 楼chenjiong(准程序员:升级中....)回复于 2001-04-10 11:03:00 得分 0
呵呵,还是不懂。Database1是指什么?Top
6 楼chenjiong(准程序员:升级中....)回复于 2001-04-10 12:54:00 得分 0
能加上注释不?Top
7 楼taogou(下面?没有了)回复于 2001-04-10 13:05:00 得分 0
database1,不就是一个控件了!Top
8 楼chenjiong(准程序员:升级中....)回复于 2001-04-10 13:09:00 得分 0
您真聪明!Top
9 楼chenjiong(准程序员:升级中....)回复于 2001-04-10 13:10:00 得分 0
哪位兄弟能解释几句听听,对帮助中的那段代码。Top
10 楼chenjiong(准程序员:升级中....)回复于 2001-04-10 14:31:00 得分 0
自己弄了会,出来一个no sql statement available的出错信息来,是在我更改了查询出的记录后出现的,什么意思?Top
11 楼chenjiong(准程序员:升级中....)回复于 2001-04-10 14:35:00 得分 0
难道是要在什么地方写上sql语句?在updatesql上写?我的那段语句是在query1的afterpost中加上:table1.close;
datasource1.dataset:=query1;
query1.applyUpdates;
结果是会出提示,确定后能改变记录,但不能保存。Top
12 楼chenjiong(准程序员:升级中....)回复于 2001-04-10 15:27:00 得分 0
ok,行了,自己解决了。多谢名位。
Top
13 楼yaoyaozhang(瑶瑶)回复于 2001-08-23 09:45:32 得分 35
结帐了。Top




