我用了两个adoquery,adoquery1用来将数据库中符合条件的记录删除,并插入新的记录(使用需要,只能先把原来的记录删掉,再把新的记录插入),到此还都能够实现,但是插入完后,我立即用adoquery2来查询符合条件的记录数,比如我原来符合条件的记录数是5条,我全删掉后,又立即插入6条符合条件的记录,可用adoquery2来查询记录数时,adoquery2.count确还是5,只有过几秒种后再查时才能为6,这是为什么?我必须用两个adoquery,因为adoquery2我作为teechart中一个series的datasource,并且series的x,y轴的datasouce我都赋予了查询中的字段,结果我每次按执行按钮至少两次,才能在series中正确显示插入后的记录图!sos!
解决方案 »
- 窗口自适应分辨率问题?????
- 呵呵,又很久没来了。谁现在失业???
- 我有一些SQL几年的数据,简体中文的,现想转成繁体的。
- 怎么样将用extractfilepath(application.exename)取得的路经修改?
- 最近学习了Delphi(走马观花式的),发现它真是个好东西,但是.....
- 如何判断中文英文字符的长度?
- 如果这样的情况建立索引有效果吗?
- 一般开发游戏都用什么工具?
- 如何取得别得窗口得数据!?
- 紧急求助!!!!nt/95无盘站得奇怪问题,没有资料介绍此错误
- 如何控制报表打印走纸尺寸?
- 想问问各位:COM+技术现在是不是已经过时? 如果是,现在的.net架构是用什么代替COM+的?
adoquery2.sql.add('select * from 你的表字');
adoquery2.open;
那样就ok
adoquery2.sql.clear;
adoquery2.sql.add('select * from 你的表字');
adoquery2.open;
那样就ok
begin
result := true;
try
if DOQuery.Active = true then
DOQuery.Close;
DOQuery.SQL.Text := szSql;
DOQuery.Connection := Conn;
DOQuery.Open;
except
result := false;
end;
end;
这样 ——〉
function OpenADOQuery(Conn: TADOConnection; DOQuery: TADOQuery; szSql: string): Boolean;
begin
result := true;
try
if DOQuery.Active = true then
DOQuery.Close;
DOQuery.SQL.Text := szSql;
DOQuery.Connection := Conn;
DOQuery.Open;
except
result := false;
end;
end;
这样应该可以了.
楼主的语句没有错误
数据库更新是需要时间的你可以先这样试试
我是指插入完后
ADOQuery.Open;
ADOQuery.Close;
adoquery2的值是从表里面选出的那部分放在内存里的!当然不会改变
要改变就要刷新
if Adoquery2.active then Adoquery2.close;
Adoquery2.disablecontrols;
Adoquery2.clear;
Adoquery2.sql.text:='select 你的数据';
Adoquery2.open;
Adoquery2.EnableControls;
ConnectString = 'Provider=Microsoft.Jet.OLEDB.4.0;'+
'Data Source= %s\Data\zz.mdb;Persist Security Info=false';
AdoQUery.ConnectionString := Format(ConnectString, [ExtractFilePath(Application.ExeName)]); if not FileExists(ExtractFilePath(Application.ExeName) + '\Data\zz.mdb') then
Begin
ShowErrMsg(ErrorConnectDataBase);
Application.Terminate;
end
else begin
Try
AdoQUery.Connection;
except
ShowErrMsg(ErrorConnectDataBase);
Application.Terminate;
end;
end;
end;
我在窗口创建时,已经把每个adoquery都用上面的语句与数据库建立连接了!而我把ADOConnection的ConnectionString属性也是用上面的ConnectString来赋的值啊,
ADOConnection1.ConnectionString:=Format(ConnectString, [ExtractFilePath(Application.ExeName)]);