我快疯了。简单点讲,用的是2000sql server,有这样一个过程,
a(data:Tquery;com:string);
begin
data.close;
data.sql.clear;
data.sql.add(com);
data.sql.open;
end;b()
begin
a(query1,'select * from table1');
a(query2,'select * from table2');
a(query3,'select * from table3');
a(query4,'select * from table4');
...............................
a(query10,'select * from table1o');
end;
我每次执行b时,有时会有这样的错误。
key violation
General sql error
[microsoft][ODBC][sql server driver]
Conncetion is busy with result for another hstmt
当我删除掉b中的某行代码时(当然这要靠运气)或者只留一行代码,就不会有错。
当Tquery的RequestLive为False时或者表里没有数据时不会有这样的错误
谁能解必给1000

解决方案 »

  1.   

    a(data:Tquery;com:string);
    begin
    data.close;
    data.sql.clear;
    data.sql.add(com);
    data.sql.open;
    Data.Close;//////////试一下
    end;
      

  2.   

    同意“挂月”
    因为你频繁打开关闭query,若你的query是单独和sql server相连
    那就非常占用资源,可用一个database连sql server 所有的query连到database上
      

  3.   

    需要这么做吗?我一般习惯这样
    a(data:Tquery;com:string);
    begin
    data.close;
    data.sql.clear;
    data.sql.add(com);
    data.sql.open;
    data.close;
    end;b()
    begin
    a(query1,'select * from table1');
    .....
    a(query1,'select * from table2');
    ......
    a(query1,'select * from table3');
    ......
    a(query1,'select * from table4');
    ...............................
    a(query1,'select * from table1o');
    end;
      

  4.   

    就是因为频繁的打开关闭query造成的.