不行啊,整个数据库有4096个这样的表要处理,开两个一起要22个小时,所以能够每个表缩短10秒,就可以节省很多时间,<br>代码如下:<br>procedure TForm1.Button5Click(Sender: TObject);<br>var<br> i,j,ii,jj,rec,iii1,iii2,k,pd,ccpd,gsh,ff,mm: integer;<br> dstr,str,str1: String;<br>begin<br> closeallbut();<br> DBGrid1.Visible:=True;<br> For ii:=1 to 64 do<br> begin<br> ADOQuery4.Close;<br> ADOQuery4.SQL.Clear;<br> ADOQuery4.SQL.Add('SELECT * From 验证状态表 where 序号='+IntToStr(ii));<br> ADOQuery4.Open;<br> if ADOQuery4.FieldByName('lock').AsInteger=0 then<br> begin<br> ADOQuery4.Edit;<br> ADOQuery4.FieldByName('lock').AsInteger:=1;<br> ADOQuery4.Post;<br> iii1:=ADOQuery4.FieldByName('ii1').AsInteger;<br> iii2:=ADOQuery4.FieldByName('序号').AsInteger;<br> Gauge1.MaxValue:=StrToInt(Edit2.Text);<br> For i:=StrToInt(Edit1.Text) to StrToInt(Edit2.Text) do<br> begin<br> Gauge1.Progress:=i;<br> StatusBar1.Panels[2].Text:=' 信息提取中......'+Edit2.Text+'/'+IntToStr(i);<br> application.ProcessMessages;<br> ADOQuery1.Close;<br> ADOQuery1.SQL.Clear;<br> ADOQuery1.Close;<br> ADOQuery1.SQL.Clear;<br> ADOQuery1.SQL.Add('SELECT * From 信息 where 序号='+IntToStr(i));<br> ADOQuery1.Open;<br> For k:=1 to 24 do<br> begin<br> pd1[i,k]:=ADOQuery1.FieldByName('pd'+IntToStr(k)).AsInteger;<br> end;<br> for j:=1 to 8 do<br> begin<br> if pdstop='stop' then<br> begin<br> ADOQuery4.Edit;<br> ADOQuery4.FieldByName('lock').AsInteger:=0;<br> ADOQuery4.Post;<br> ADOQuery4.Close;<br> ADOQuery4.SQL.Clear;<br> ADOQuery5.Close;<br> ADOQuery5.SQL.Clear;<br> openallbut();<br> exit;<br> end;<br> xs[i,j,0]:=0;<br> xs[i,1,j]:=ADOQuery1.FieldByName('a'+IntToStr(j)).AsInteger;<br> xs[i,2,j]:=ADOQuery1.FieldByName('b'+IntToStr(j)).AsInteger;<br> xs[i,3,j]:=ADOQuery1.FieldByName('c'+IntToStr(j)).AsInteger;<br> xs[i,4,j]:=ADOQuery1.FieldByName('d'+IntToStr(j)).AsInteger;<br> xs[i,5,j]:=ADOQuery1.FieldByName('e'+IntToStr(j)).AsInteger;<br> xs[i,6,j]:=ADOQuery1.FieldByName('f'+IntToStr(j)).AsInteger;<br> xs[i,7,j]:=ADOQuery1.FieldByName('g'+IntToStr(j)).AsInteger;<br> xs[i,8,j]:=ADOQuery1.FieldByName('h'+IntToStr(j)).AsInteger;<br> end;<br> end;<br> ADOQuery1.Close;<br> ADOQuery1.SQL.Clear;<br> StatusBar1.Panels[2].Text:=' 信息提取完毕!';<br> application.ProcessMessages;<br> For gsh:=iii1 to iii2*64 do<br> begin<br> ADOQuery4.Close;<br> ADOQuery4.SQL.Clear;<br> ADOQuery4.SQL.Add('SELECT * From 验证状态表 where 序号='+IntToStr(ii));<br> ADOQuery4.Open;<br> ADOQuery4.Edit;<br> ADOQuery4.FieldByName('ii1').AsInteger:=gsh;<br> ADOQuery4.Post;<br> rec:=ADOQuery4.FieldByName('no').AsInteger;<br> ADOQuery5.Close;<br> ADOQuery5.SQL.Clear;<br> ADOQuery5.SQL.Add('SELECT * From 全部公式'+IntToStr(gsh)+' order by 序号');<br> ADOQuery5.Open;<br> ADOQuery5.RecNo:=rec;<br> Gauge1.MaxValue:=ADOQuery5.RecordCount;<br> Gauge1.Progress:=0;<br> dstr:=TimeToStr(Now);<br> str1:=IntToStr((ff*60+mm)*((iii2*64)-gsh) div 3600)+'小时'+IntToStr(((ff*60+mm)*((iii2*64)-gsh) mod 3600) div 60)+'分'+IntToStr(((ff*60+mm)*((iii2*64)-gsh) mod 3600) mod 60)+'秒'+'('+IntToStr(ff)+'分'+IntToStr(mm)+'秒)!';<br> For i:=rec to Gauge1.MaxValue do<br> begin<br> if pdstop='stop' then<br> begin<br> ADOQuery4.Edit;<br> ADOQuery4.FieldByName('lock').AsInteger:=0;<br> ADOQuery4.Post;<br> ADOQuery4.Close;<br> ADOQuery4.SQL.Clear;<br> ADOQuery5.Close;<br> ADOQuery5.SQL.Clear;<br> openallbut();<br> exit;<br> end;<br> Gauge1.Progress:=i;<br> StatusBar1.Panels[2].Text:=' 公式提取中(当前64/'+IntToStr(ii)+'-'+IntToStr(iii2*64)+'/'+IntTostr(gsh)+')......, 剩余'+IntToStr(iii2*64-gsh)+'个表,需时:'+str1;<br> application.ProcessMessages;<br> bii[i,1]:=ADOQuery5.FieldByName('i1').AsInteger;<br> bii[i,2]:=ADOQuery5.FieldByName('i2').AsInteger;<br> bii[i,3]:=ADOQuery5.FieldByName('i3').AsInteger;<br> bii[i,4]:=ADOQuery5.FieldByName('i4').AsInteger;<br> bii[i,5]:=ADOQuery5.FieldByName('i5').AsInteger;<br> bii[i,6]:=ADOQuery5.FieldByName('i6').AsInteger;<br> bii[i,7]:=ADOQuery5.FieldByName('i7').AsInteger;<br> bii[i,8]:=ADOQuery5.FieldByName('i8').AsInteger;<br> ADOQuery5.Next;<br> end;<br> For i:=rec to Gauge1.MaxValue do<br> begin<br> For j:=0 to 286 do<br> begin<br> cwcs[i,j]:=0;<br> end;<br> end;<br> For i:=rec to Gauge1.MaxValue do<br> begin<br> if pdstop='stop' then<br> begin<br> ADOQuery4.Edit;<br> ADOQuery4.FieldByName('lock').AsInteger:=0;<br> ADOQuery4.Post;<br> ADOQuery4.Close;<br> ADOQuery4.SQL.Clear;<br> ADOQuery5.Close;<br> ADOQuery5.SQL.Clear;<br> openallbut();<br> exit;<br> end;<br> Gauge1.Progress:=i;<br> StatusBar1.Panels[2].Text:=' 公式运算中(当前64/'+IntToStr(ii)+'-'+IntToStr(iii2*64)+'/'+IntTostr(gsh)+')......, 剩余'+IntToStr(iii2*64-gsh)+'个表,需时:'+str1;<br> application.ProcessMessages;<br> ccpd:=0;<br> For j:=StrToInt(Edit1.Text) to (StrToInt(Edit2.Text)-1) do<br> begin<br> pd:=xs[j,1,bii[i,1]]+xs[j,2,bii[i,2]]+xs[j,3,bii[i,3]]+xs[j,4,bii[i,4]]+xs[j,5,bii[i,5]]+xs[j,6,bii[i,6]]+xs[j,7,bii[i,7]]+xs[j,8,bii[i,8]];<br> For k:=1 to 16 do<br> begin<br> if pd mod pdzz[k]<>pd1[j+1,k] then<br> begin<br> For jj:=0 to ccpd do<br> begin<br> cwcs[i,k+(10-jj)*26]:=cwcs[i,k+(10-jj)*26]+1;<br> end;<br> end;<br> end;<br> For k:=17 to 24 do<br> begin<br> if pd mod pdzz[k]=pd1[j+1,k] then<br> begin<br> For jj:=0 to ccpd do<br> begin<br> cwcs[i,k+(10-jj)*26]:=cwcs[i,k+(10-jj)*26]+1;<br> end;<br> end;<br> end;<br> if (pd mod 10<>xs[j+1,1,3]) and (pd mod 10<>xs[j+1,2,3]) and (pd mod 10<>xs[j+1,3,3]) and (pd mod 10<>xs[j+1,4,3]) and (pd mod 10<>xs[j+1,5,3]) and (pd mod 10<>xs[j+1,6,3]) then<br> begin<br> For jj:=0 to ccpd do<br> begin<br> cwcs[i,25+(10-jj)*26]:=cwcs[i,25+(10-jj)*26]+1;<br> end;<br> end;<br> if (pd mod 12<>xs[j+1,1,6]) and (pd mod 12<>xs[j+1,2,6]) and (pd mod 12<>xs[j+1,3,6]) and (pd mod 12<>xs[j+1,4,6]) and (pd mod 12<>xs[j+1,5,6]) and (pd mod 12<>xs[j+1,6,6]) then<br> begin<br> For jj:=0 to ccpd do<br> begin<br> cwcs[i,26+(10-jj)*26]:=cwcs[i,26+(10-jj)*26]+1;<br> end;<br> end;<br> ccpd:=ccpd+1;<br> end;<br> cwcs[i,0]:=xs[StrToInt(Edit2.Text),1,bii[i,1]]+xs[StrToInt(Edit2.Text),2,bii[i,2]]+xs[StrToInt(Edit2.Text),3,bii[i,3]]+xs[StrToInt(Edit2.Text),4,bii[i,4]]+xs[StrToInt(Edit2.Text),5,bii[i,5]]+xs[StrToInt(Edit2.Text),6,bii[i,6]]+xs[StrToInt(Edit2.Text),7,bii[i,7]]+xs[StrToInt(Edit2.Text),8,bii[i,8]];<br> end;<br> ADOQuery4.Close;<br> ADOQuery4.SQL.Clear;<br> ADOQuery4.SQL.Add('SELECT * From 验证状态表 where 序号='+IntToStr(ii));<br> ADOQuery4.Open;<br> ADOQuery5.RecNo:=rec;<br> For i:=rec to Gauge1.MaxValue do<br> begin<br> Gauge1.Progress:=i;<br> StatusBar1.Panels[2].Text:=' 结果保存中(当前64/'+IntToStr(ii)+'-'+IntToStr(iii2*64)+'/'+IntTostr(gsh)+')......, 剩余'+IntToStr(iii2*64-gsh)+'个表,需时:'+str1;<br> application.ProcessMessages;<br> ADOQuery4.Edit;<br> ADOQuery4.FieldByName('no').AsInteger:=ADOQuery5.RecNo;<br> ADOQuery4.Post;<br> if pdstop='stop' then<br> begin<br> ADOQuery4.Edit;<br> ADOQuery4.FieldByName('lock').AsInteger:=0;<br> ADOQuery4.Post;<br> ADOQuery4.Close;<br> ADOQuery4.SQL.Clear;<br> ADOQuery5.Close;<br> ADOQuery5.SQL.Clear;<br> openallbut();<br> exit;<br> end;<br> ADOQuery5.Edit;<br> For j:=0 to 286 do<br> begin<br> DBGrid1.fields[j+1].AsInteger:=cwcs[i,j];<br> end;<br> ADOQuery5.Next;<br> end;<br> str:=DateTimeToStr(Now()-StrtoDateTime(dstr));<br> ff:=MinuteOf(StrtoDateTime(str));<br> mm:=SecondOf(StrtoDateTime(str));<br> Memo1.Lines.Add(IntToStr(ff*60+mm));<br> ADOQuery4.Close;<br> ADOQuery4.SQL.Clear;<br> ADOQuery4.SQL.Add('SELECT * From 验证状态表 where 序号='+IntToStr(ii));<br> ADOQuery4.Open;<br> ADOQuery4.Edit;<br> ADOQuery4.FieldByName('no').AsInteger:=1;<br> ADOQuery4.Post;<br> end;<br> ADOQuery4.Edit;<br> ADOQuery4.FieldByName('lock').AsInteger:=10;<br> ADOQuery4.Post;<br> ADOQuery4.Close;<br> ADOQuery4.SQL.Clear;<br> end;<br> end;<br> time:=0;<br> Timer1.Enabled:=True;<br> closeallbut();<br> StatusBar1.Panels[2].Text:=' 请等待......!程序会自动运行!';<br> application.ProcessMessages;<br>end;<br><br>大家帮忙啊,我什么方法都试过了,就是不见效果