F
fstao
Unregistered / Unconfirmed
GUEST, unregistred user!
数据库是mssql7,dbo.salary_storage1大约有6000条记录,如果在Button1
的Click事件写为:
with query1 do
begin
close;
sql.clear;
sql.add('SELECT id, salary_no, name,postalcode,area_id,
units, quantity, p_level_id, sign');
sql.add('FROM dbo.Salary_Storage1 Dbo_salary_storage1 order by salary_no');
open;
end;
with query2 do
begin
close;
sql.clear;
sql.add('select count(*) from salary_storage1
Dbo_Salary_Storage1');
open;
end;
edit1.Text:='共有'+query2.Fields[0].Text+'条数据';
一执行button1时,发现要用8秒多。如果是这样写:
with query2 do
begin
close;
sql.clear;
sql.add('select count(*) from salary_storage1
Dbo_Salary_Storage1');
open;
end;
edit1.Text:='共有'+query2.Fields[0].Text+'条数据';
with query1 do
begin
close;
sql.clear;
sql.add('SELECT id, salary_no, name,postalcode,area_id,
units, quantity, p_level_id, sign');
sql.add('FROM dbo.Salary_Storage1 Dbo_salary_storage1
order by salary_no');
open;
end;
奇怪只用1秒,这是为什么?谁能够解释一下?
的Click事件写为:
with query1 do
begin
close;
sql.clear;
sql.add('SELECT id, salary_no, name,postalcode,area_id,
units, quantity, p_level_id, sign');
sql.add('FROM dbo.Salary_Storage1 Dbo_salary_storage1 order by salary_no');
open;
end;
with query2 do
begin
close;
sql.clear;
sql.add('select count(*) from salary_storage1
Dbo_Salary_Storage1');
open;
end;
edit1.Text:='共有'+query2.Fields[0].Text+'条数据';
一执行button1时,发现要用8秒多。如果是这样写:
with query2 do
begin
close;
sql.clear;
sql.add('select count(*) from salary_storage1
Dbo_Salary_Storage1');
open;
end;
edit1.Text:='共有'+query2.Fields[0].Text+'条数据';
with query1 do
begin
close;
sql.clear;
sql.add('SELECT id, salary_no, name,postalcode,area_id,
units, quantity, p_level_id, sign');
sql.add('FROM dbo.Salary_Storage1 Dbo_salary_storage1
order by salary_no');
open;
end;
奇怪只用1秒,这是为什么?谁能够解释一下?