delphi中,我用定時器每隔一段時間執行數據庫插入及更新工做!
adoquery.close;
adoquery.sql.cleare;
adoquery.connection:=con1;
adoquery.sql.add('exec addery');
execsql;
上面的基本語句!
個人問題是:定時器執行時,在軟件界面就會很卡,沒法操做!請問是否是須要建立一個線程才能處理卡的問題呢?請大神們幫幫忙!很是感謝!若是是須要寫線程,更但願能把線程也寫出來!很是感謝!web
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, DB, ADODB;
type
TForm1 = class(TForm)
BitBtn1: TBitBtn;
ADOConnection1: TADOConnection;
procedure BitBtn1Click(Sender: TObject);
private
public
end;
Type
TAdoExec = Class(TThread)
Private
Public
Protected
Procedure Execute; Override;
End;
var
Form1: TForm1;
implementation
uses ActiveX;
{$R *.dfm}
{ TAdoExec }
procedure TAdoExec.Execute;
begin
Inherited;
ActiveX.CoInitialize(Nil);
Try
With TADOQuery.Create(Nil) Do
Begin
ConnectionString :=
'Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=TEST;Data Source=.';
SQL.Add('Select * From Tree');
ExecSQL;
Free;
End;
Finally
ActiveX.CoUninitialize;
Terminate;
End;
end;
procedure TForm1.BitBtn1Click(Sender: TObject);
begin
TAdoExec.Create(False);
end;
end.sql