@Lemmy: Jasucol hat es genau auf den Punkt getroffen. Das ist es was ich meine.
@All:
Einen anscheinend geeigneten Thread habe ich dazu auch schon, jedoch funktioniert die Übergabe der Daten zur Anwendung noch nicht:
Delphi-Quellcode:
unit SQLThread;
interface
uses
Classes, ADODB, ComObj,
ActiveX, SysUtils,
Funktionen, Dialogs;
type
TSQLThread =
class(TThread)
private
FQType :
string;
FQSQL :
string;
Fqry : TADOQuery;
Fcmd : TADOCommand;
FExceptionMessage:
string;
function GetConnectionString:
String;
procedure DoDataToVCL_VST;
published
property QType:
string read FQType
write FQType;
property QSQL:
string read FQSQL
write FQSQL;
property qry: TADOQuery
read Fqry
write Fqry;
property cmd: TADOCommand
read Fcmd
write Fcmd;
protected
procedure Execute;
override;
public
// constructor Create(OnTerminate: TNotifyEvent);
constructor Create;
destructor Destroy;
override;
property ExceptionMessage:
string read FExceptionMessage;
end;
implementation
uses main;
//------------------------------------------------------------------------------
//constructor TSQLThread.Create(OnTerminate: TNotifyEvent);
constructor TSQLThread.Create;
begin
inherited Create(True);
// Self.OnTerminate:=OnTerminate;
// FreeOnTerminate:=True;
Resume;
end;
//------------------------------------------------------------------------------
destructor TSQLThread.Destroy;
begin
Free;
end;
//------------------------------------------------------------------------------
procedure TSQLThread.Execute;
Var
qry : TADOQuery;
cmd : TADOCommand;
begin
{ Place thread code here }
try
CoInitialize(
nil);
try
if QType = '
qry'
then
begin
qry:=TADOQuery.Create(
nil);
try
qry.ConnectionString := GetConnectionString;
qry.CommandTimeout := 3000;
qry.SQL.Clear;
qry.SQL.Text := QSQL;
qry.Open;
while not qry.Eof
do
begin
//Verarbeitung mit der Anwendung - Daten zur Anwendung schicken
// Synchronize(DoDataToVCL_VST);
qry.Next;
end;
qry.Close;
finally
qry.Free;
end;
end else
begin
cmd := TADOCommand.Create(
nil);
try
cmd.ConnectionString := GetConnectionString;
cmd.CommandTimeout := 3000;
cmd.CommandText := QSQL;
cmd.Execute;
finally
cmd.Free;
end;
end;
finally
CoUnInitialize;
end;
except
on E:
Exception do FExceptionMessage:=E.
Message;
end;
end;
//------------------------------------------------------------------------------
function TSQLThread.GetConnectionString:
string ;
var ConnectionString: WideString;
begin
ConnectionString:='
Provider=MSDAORA.1;'+
'
Password=xxxxx;'+
'
User ID=xxxxx;'+
'
Data Source=xxxxx;'+
'
Persist Security Info= true';
Result:=ConnectionString;
end;
//------------------------------------------------------------------------------
procedure TSQLThread.DoDataToVCL_VST;
begin
Form_Main.StatusBar.Panels[0].Text:='
Test';
Form_Main.StatusBar.Update;
end;
end.
Vielleicht gibt es ja dazu ein paar Tipps?
MfG
schuetze09