是这样的,有二个表之间有关联关系。而且二个表的数据量都很大,原来是这样写的。
table1.first;
while not table1.eof do 
begin
  xh:=table1.fieldbyname('xh').asstring;
  query1.Close;
  query1.SQL.Text:='select * from table2 where xh='''+xh+''';
  query1.Open;
  if quey1.IsEmpty then exit;
  query1.first;
  while not query1.eof do 
  begin
    .......
    取出的值再进行下一步计算。
  end;
end;
这觉得这样很慢,有没有比这快的方法。求赐教!

解决方案 »

  1.   

    将计算逻辑放入一个SQL中完成。
      

  2.   

    1.改用存储过程实现逻辑
    2.包上disablecontrol和enablecontrols
      

  3.   

    直接用SQL计算撒, 查询出来直接显示
      

  4.   

    select * from table2 where exists (select xh from table1 where table2.xh=table1.xh) order by xh然后循环这里面的每条记录行了。
      

  5.   

    while循环都是0.X微妙级别的.跟你的Query1.Open比起来一个天上一个地下.
    把你的Query1一次性都查出来,然后在本地再做一次While找比你一次次操作数据库快多了.