Re: Anwendung friert bei SQL ein
@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:
Vielleicht gibt es ja dazu ein paar Tipps?
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. MfG schuetze09 |
Re: Anwendung friert bei SQL ein
Hi,
gut, wenn die Anwender da freie SQL eingeben können wird es schwierig.... Zum Thread: Wo genau hast Du ein Problem? |
Re: Anwendung friert bei SQL ein
@Lemmy: Ich glaube ich habe es gelöst. Ich hatte beim Synchronize Probleme.
MfG schuetze09 |
Alle Zeitangaben in WEZ +1. Es ist jetzt 07:02 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz