unit MySQL;
interface
uses Windows, Forms, Messages, SysUtils, Variants, Classes, Graphics, Controls,
DB, ZQuery, ZMySqlQuery, ZTransact, ZMySqlTr, ZConnect, ZMySqlCon;
type TMySQL = class(TThread)
Database: TZMySqlDatabase;
Transact: TZMySqlTransact;
Query: TZMySqlQuery;
public
constructor Create(CreateSuspendend : BOOLEAN);
destructor Destroy;
procedure DoQueryResultGlobal;
protected
procedure Execute; override;
end;
implementation
uses Unit1;
constructor TMySQL.Create;
begin
Database := TZMySqlDatabase.Create(nil);
Transact := TZMySqlTransact.Create(nil);
Query := TZMySqlQuery.Create(nil);
Transact.Database := Database;
Query.Database := DAtabase;
Database.Login:='Benutzername';
Database.Password:='Passwort';
Database.Database:='Deine Gewollte
DB';
inherited Create(FALSE);
end;
procedure TMySQL.DoQueryResultGlobal;
begin
Form1.DataSource.DataSet:=
Query;
Query.Active:=true;
end;
procedure TMySQL.Execute;
const
WM_REFRESHAFTERQUERY= WM_USER+1001;
begin
Query.Sql.Add('SELECT * FROM Tabelle;');
Synchronize(DoQueryResultGlobal);
PostMessage (
Handle, WM_REFRESHAFTERQUERY, 0, 0);
Application.ProcessMessages;
end;
destructor TMySQL.Destroy;
begin
Database.Free;
Transact.Free;
Query.Free;
inherited Destroy;
end;