程序的启动速度太慢?
fj321 2005-04-28 01:53:38 大侠们,我是个初学者,写了一个程序,可启动的速度太慢了,主要是form1要启动二十秒左右,其它几个form都很快,请问该怎么办,下面是我form1的oncreate和onshow事业,请大侠指点:
procedure TForm1.FormCreate(Sender: TObject);
begin
query1.databasename:=extractfiledir(application.exename);
query1.Active:=true;
query2.databasename:=extractfiledir(application.exename);
query2.Active:=true;
query3.databasename:=extractfiledir(application.exename);
query3.Active:=true;
adoquery1.ConnectionString:='Provider=Microsoft.Jet.OLEDB.4.0;'+'Data Source='+extractfiledir(application.exename)+'\record.mdb';
adoquery1.active:=true;
adoquery2.ConnectionString:='Provider=Microsoft.Jet.OLEDB.4.0;'+'Data Source='+extractfiledir(application.exename)+'\record.mdb';
adoquery2.active:=true;
adoquery3.ConnectionString:='Provider=Microsoft.Jet.OLEDB.4.0;'+'Data Source='+extractfiledir(application.exename)+'\record.mdb';
adoquery3.active:=true;
with query3 do
begin
close;
sql.clear;
try
sql.add('select show.xh,show.xm,dwdm.dwmc,show.riqi,show.sksj,show.skcs,show.ljsj from show,dwdm where show.xksj is null and dwdm.dw=show.dw');
open;
label6.Caption:=inttostr(query3.recordcount);
except
sql.clear;
end;
end;
end;
procedure TForm1.FormShow(Sender: TObject);
begin
table1.databasename:=extractfiledir(application.exename);
table1.TableName:='show.db';
table1.Active:=true;
with adoquery1 do
begin
close;
sql.clear;
try
sql.add('select * from 讲座信息 where 日期=:riqi');
adoquery1.Parameters.parambyname('riqi').value:=date;
Open;
except
sql.clear;
end;
if adoquery1.recordcount>=1 then
begin
adoquery1.Last;
cc:=adoquery1.fields[5].value;
label4.Visible:=true;
label4.Caption:=datetostr(date);
label3.Visible:=true;
label3.Caption:=adoquery1.fields[1].value;
label5.Visible:=true;
label5.caption:='主讲人:'+adoquery1.fields[2].value+inttostr(cc);
timer1.Enabled:=true;
end
else begin
timer1.Enabled:=false;
if messagedlg('请先进行讲座信息设定!',mtconfirmation,[mbyes,mbno],0)=mryes then
begin
PostMessage(Handle, WM_SHOWFORM2, 0, 0);
end
else
form1.Close;
end;
end;
end;