delphi中我用定时器每隔一段时间执行操作
2021-05-18 05:28
标签:unit ffffff nbsp ecs highlight err 一个 creat ide delphi中,我用定时器每隔一段时间执行数据库插入及更新工作! unit Unit1; delphi中我用定时器每隔一段时间执行操作 标签:unit ffffff nbsp ecs highlight err 一个 creat ide 原文地址:https://www.cnblogs.com/jijm123/p/11747258.html
adoquery.close;
adoquery.sql.cleare;
adoquery.connection:=con1;
adoquery.sql.add(‘exec addery‘);
execsql;
上面的基本语句!
我的问题是:定时器执行时,在软件界面就会很卡,无法操作!请问是不是需要创建一个线程才能处理卡的问题呢?请大神们帮帮忙!非常感谢!如果是需要写线程,更希望能把线程也写出来!非常感谢!
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.
上一篇:Delphi中进行延时的4种方法
文章标题:delphi中我用定时器每隔一段时间执行操作
文章链接:http://soscw.com/index.php/essay/87044.html