unit MainUnit;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,ZConnection,
DB,ZAbstractRODataset,ZAbstractDataset,ZDataset, StdCtrls;
type
TForm1 =
class(TForm)
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject;
var Action: TCloseAction);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
UserDBConnection: TZConnection;
ServerConnection: TZConnection;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
UserDBConnection.Disconnect;
USerDBConnection.Free;
ServerConnection.Disconnect;
{ Zugriffsverletzung -901 Invalid Transaction Handle }
ServerConnection.Free;
end;
procedure TForm1.FormCreate(Sender: TObject);
var WideStr: WideString;
FQuery: TZQuery;
f: textfile;
s:
string;
begin
UserDBConnection:=TZConnection.Create(Self);
UserDBConnection.Database:='
T:\test.fdb';
UserDBConnection.Protocol:='
firebirdd-2.0';
UserDBConnection.User:='
SYSDBA';
UserDBConnection.Connect;
FQuery:=TZQuery.Create(
nil);
FQuery.Connection:= UserDBConnection;
WideStr:='
SELECT * FROM BENUTZER';
with FQuery
do
begin
SQL.Clear;
SQL.Add(WideStr);
Open;
end;
Label1.Caption:='
UserDB: '+IntToStr(FQuery.RecordCount)+'
Einträge';
FQuery.Free;
ServerConnection:=TZConnection.Create(Self);
ServerConnection.Database:='
MATERIALSTAMM';
ServerConnection.Protocol:='
firebird-2.0';
ServerConnection.User:='
FRANZ';
ServerConnection.Password:='
nix';
ServerConnection.HostName:='
localhost';
ServerConnection.Connect;
FQuery:=TZQuery.Create(
nil);
FQuery.Connection:= ServerConnection;
WideStr:='
SELECT * FROM MATERIAL';
with FQuery
do
begin
SQL.Clear;
SQL.Add(WideStr);
Open;
end;
Label2.Caption:='
ServerDB: '+IntToStr(FQuery.RecordCount)+'
Einträge';
FQuery.Free;
{ Diese Abfrage macht Tabelleabfrage auf Server, nicht von Embedded ??? }
FQuery:=TZQuery.Create(
nil);
FQuery.Connection:= UserDBConnection;
WideStr:='
SELECT * FROM BENUTZER';
with FQuery
do
begin
SQL.Clear;
SQL.Add(WideStr);
Open;
end;
Label3.Caption:='
UserDB: '+IntToStr(FQuery.RecordCount)+'
Einträge';
FQuery.Free;
end;
end.