Type
Tmythread = Class (TThread)
Private
Fquery:tadoquery; Inquire
Fconnection:tadoconnection; Connection
Fdatasource:tdatasource; {data-aware component associated with the query component}
Procedure Connectdatasource; {Methods for connecting data query components and data-aware components}
Protected
Procedure Execute; Override
Public
Constructor Create (Suspended:boolean; Query:tadoquery;ds:tdatasource); {Thread Builder}
destructor Destroy;override;
End
Implementation
Procedure Tmythread.connectdatasource; {Methods for connecting data query components and data-aware components}
Begin
Fdatasource.dataset:=fquery;
End
Constructor Tmythread.create (Suspended:boolean; Query:tadoquery;ds:tdatasource);
Begin
CoInitialize (nil); is required in this thread
Try
Fconnection:=tadoconnection.create (nil);
Fquery:=query;
Fdatasource:=ds;
Fquery.connection:=fconnection;
With Fconnection do
Begin
Loginprompt:=false;
Keepconnection:=true;
Connectionstring:= ' provider=msdasql.1; Persist security Info=false;data source=honesty ';
End
Inherited Create (suspended);
Except
On E:exception do
Begin
ShowMessage (' Error creating thread! Error: ' + e.message ');
End
End
End
destructor Tmythread.destroy;
Begin
Fconnection.free; Release
CoUninitialize;
Inherited Destroy;
End
Procedure Tmythread.execute;
Begin
Try
Freeonterminate: = true;
Fquery.open; {Open Query}
Synchronize (Connectdatasource); {Thread Synchronization}
Except
ShowMessage (' thread exception! '); {Thread Exception}
End
End
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service