procedure TMainFrm.XTConnection;
var
Recnum1:array of string;
AShape:Array[0..75] of TShape;
hy :Double;
i: integer;
s3, s1,s2:TDateTime;
date :String;
begin
setlength(recnum1,75);
Query2.Close;
Query2.SQL.Text :='select Max(recnum)as recnum,line_num,tower_num from history_data where isolate_num='+'0001'+ 'group by line_num,tower_num';
Query2.Open;
Query2.First;
for i:=0 to Query2.RecordCount -1 do
begin
Recnum1[i] :=inttostr(Query2.fieldbyname('recnum').AsInteger);
Query2.Next;
end; setlength(recnum1,75);
for i :=Low(Recnum1) to High(Recnum1) do
begin
Query3.Close;
Query3.SQL.Text :='SELECT c.* FROM line a INNER JOIN'+
' tower b ON a.line_num = b.line_num INNER JOIN'+
' history_data c ON a.line_num = c.line_num AND b.tower_num = c.tower_num AND'+
' isolate_num='+'0001'+'and c.recnum =' + QuotedStr(recnum1[i]);
Query3.Open;
s1:=StrToDateTime(formatdatetime('yyyy-mm-dd',now));
s2:=StrToDateTime(formatdatetime('hh:mm:ss',time));
s3:=s1+s2;
date :=FormatDateTime('yyyy-mm-dd hh:mm:ss', s3);
DateRQ:=DateTimeToStr(Query3.fieldbyname('riqi').AsDateTime); if (StrToDateTime(date) - StrToDateTime(DateRQ))*24 >48 then
begin
if i<5 then
TShape(FindComponent('Shape'+inttostr(i))).Brush.Color :=clRed;
end;
hy :=(StrToDateTime(date) - StrToDateTime(DateRQ))*24;
if ( hy > 24) and (hy <= 48) then
begin
if i<5 then
TShape(FindComponent('Shape'+inttostr(i))).Brush.Color :=clYellow;
end;
end;
end;
这个过程是在FormCreate事件中执行,显的非常的慢,请各位帮帮忙,有没有什么好的优化方法,在线感谢
var
Recnum1:array of string;
AShape:Array[0..75] of TShape;
hy :Double;
i: integer;
s3, s1,s2:TDateTime;
date :String;
begin
setlength(recnum1,75);
Query2.Close;
Query2.SQL.Text :='select Max(recnum)as recnum,line_num,tower_num from history_data where isolate_num='+'0001'+ 'group by line_num,tower_num';
Query2.Open;
Query2.First;
for i:=0 to Query2.RecordCount -1 do
begin
Recnum1[i] :=inttostr(Query2.fieldbyname('recnum').AsInteger);
Query2.Next;
end; setlength(recnum1,75);
for i :=Low(Recnum1) to High(Recnum1) do
begin
Query3.Close;
Query3.SQL.Text :='SELECT c.* FROM line a INNER JOIN'+
' tower b ON a.line_num = b.line_num INNER JOIN'+
' history_data c ON a.line_num = c.line_num AND b.tower_num = c.tower_num AND'+
' isolate_num='+'0001'+'and c.recnum =' + QuotedStr(recnum1[i]);
Query3.Open;
s1:=StrToDateTime(formatdatetime('yyyy-mm-dd',now));
s2:=StrToDateTime(formatdatetime('hh:mm:ss',time));
s3:=s1+s2;
date :=FormatDateTime('yyyy-mm-dd hh:mm:ss', s3);
DateRQ:=DateTimeToStr(Query3.fieldbyname('riqi').AsDateTime); if (StrToDateTime(date) - StrToDateTime(DateRQ))*24 >48 then
begin
if i<5 then
TShape(FindComponent('Shape'+inttostr(i))).Brush.Color :=clRed;
end;
hy :=(StrToDateTime(date) - StrToDateTime(DateRQ))*24;
if ( hy > 24) and (hy <= 48) then
begin
if i<5 then
TShape(FindComponent('Shape'+inttostr(i))).Brush.Color :=clYellow;
end;
end;
end;
这个过程是在FormCreate事件中执行,显的非常的慢,请各位帮帮忙,有没有什么好的优化方法,在线感谢
解决方案 »
- delphi和C# 目录结构的区别
- 关于对byte数组位操作的问题
- 关于字符串转换成十六进制的问题
- delphi 中的OLE嵌入与链接问题(高分)
- 让程序自动适应分辨率时,为什么最大化的窗体可以实现,而normal窗体显示不全?谢谢
- 我想开发一个用c/s结合b/s的信息管理系统,请大家给点意见,说者有分
- 代人提问:请问.dcu文件是干什么的?如何才能生成该类型文件。
- SQL SERVER中事务的问题
- 一个dll问题连接数据库的问题?
- 请问如何在一个线程对象中添加代码来跳出某个FOR循环?
- 紧急求救。谢谢各位了
- 向各位大大请教一个字符串的处理问题(在 SQL SERVER 2000 中),谢谢!
我觉得你应该从查询这块入手,看看这些数据是不是必须在程序已开始就要读取近来,能不能放到后面进行?如果真的不能避免的话,就做一个启动窗口吧(就像delphi刚刚打开时显示的启动窗口一样,如果时间不是太长,用户应该能够忍受)