老问题:dbgrid(eh)的刷新问题(200分)

  • 主题发起人 主题发起人 flybubble
  • 开始时间 开始时间
F

flybubble

Unregistered / Unconfirmed
GUEST, unregistred user!
我的dbgrideh是通过datasource连接adoquery1显示的。现在的问题是我使用另外的adoquery或adotable去修改表后,使用 adoquery1。close adoquery1。open总是无法及时更新dbgrideh。我试了一下加一个timer后,只要设很短的时间间隔再去 adoquery1。close adoquery1。open dbgrideh就能刷新了。这个问题困扰了我很长时间,请高手解决一下,谢先!
 
adoquery.requery()里面有参数代替你的CLOSE OPEN。。。
Refreshes the recordset.

procedure Requery(Options: TExecuteOptions = []);

Description
eoAsyncExecute The command is executed asynchronously.
eoAsyncFetch The command fetches remaining rows after the initial quantity specified in the Cache property asynchronously.
eoAsyncFetchNonBlocking Execution is performed without blocking the thread.
eoExecuteNoRecords A command or stored procedure that does not return. If any rows are retrieved, they are discarded and not returned.

使用requery可以即时更新的TDATASET。呼叫刷新显示。。。
 
好像要在adoquery里设置服务器端、客户端,
具体你可看帮助,
还有游标位置等,
 
用 AdoQuery.Requery 即可
 
Requery会刷新所有记录,如果更新的记录比较少可以试试一条一条记录刷新
uses ADOInt
TBaseDataSet=class(TADODataSet)

procedure TBaseDataSet.RefreshCurrentlyRecord;
begin
UpdateCursorPos;
Recordset.Resync(AdAffectCurrent, AdResyncAllValues);
Resync([]);
end;
 
还想再具体说明一下:我是用adotable去添加记录的,但是dbgrideh是通过adoquery显示的。我在adotable的afterpost后按楼上添加语句
TBaseDataSet(adotable2).RefreshCurrentlyRecord;
出现新问题,错误提示“缺少更新或刷新的键列信息”,注:dbgrideh显示的是两个表的内容!
 
requery告诉你了,
使用refresh就是没有关键更新字错误了。。
 
楼上 :我按你的加了adoquery4.Requery([eoAsyncExecute]),但是运行时候出现了“当前程序不支持异步执行”。
 
我也一样没决解决这个问题
 
大家就 没有对这问题感兴趣的吗?200分呀!
 
“使用 adoquery1。close adoquery1。open总是无法及时更新dbgrideh”是什么意思?
不能“及时”?adoquery1。close adoquery1。open 后肯定会立即更新的。
 
我想不能刷新可能有两方面原因:
1。数据库的显示和添加记录使用了不同的数据集控件:显示使用了adoquery,添加使用了adotable;
2。adoquery显示了两个表的内容;
 
我也没解决这问题
我是用adoquery进行删除,后显示的,结果没更新,我删除后把connection都断开了,再连还是没更新。
不知道是什么原因。
 
我刷新不了时,就重新写一个SQL,然后执行这个SQL进行刷新,好象都能用,就是麻烦。不知道有没有更好的答案。
 
我刷新不了时,就重新写一个SQL,然后执行这个SQL进行刷新,好象都能用,就是麻烦。不知道有没有更好的答案。
 
楼上:你的意思是一个dbgrid控件使用两个adoquery去显示?这样好像不妥吧!
 
不是啊,还上用那个adoquery,将这个adoquery的sql语句重新付,然后再执行,试试看行不,我不知道说明白了没
 
String SQL="select * from "+sTabelName+" where "+sAudingFlag+"='0' ";
MainQry->SQL->Clear();
MainQry->SQL->Add(SQL); //
MainQry->Prepared = true;
MainQry->Open();
MainQry->close();
MainQry->Open();
这样的,看有帮助没
 
帮顶...........
 
bgqy2000:你的方法还是行不通!
 
后退
顶部