unit Unit1;
interface
uses
Windows, Messages, Controls, StdCtrls, Classes, Forms, SysUtils,
IBDatabase,
DB, IBCustomDataSet, IBQuery, IBIntf,
IB;
type
TForm1 =
class(TForm)
TestDB: TIBDatabase;
Button1: TButton;
procedure Button3Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
function CheckIBDBStatus(
DB: TIBDatabase;
var ErrCode : Integer): Boolean;
var
Form1 : TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
Var
ErrorVal : Integer;
begin
TestDB.DatabaseName := '
Server:c:\Test\Test1.gdb';
TestDB.LoginPrompt := False;
TestDB.Params.Add('
USER_NAME=TEST');
TestDB.Params.Add('
password=test');
if CheckIBDBStatus(TestDB, ErrorVal)
then
TestDB.Connected := true
else
Begin
TestDB.DatabaseName := '
Server:c:\Test\Test2.gdb';
TestDB.Connected := true;
end;
TestDB.Connected := False;
end;
function CheckIBDBStatus(
DB: TIBDatabase;
var ErrCode : Integer): Boolean;
Var
GDSL : IGDSLibrary;
DPB :
String;
DPBLength : short;
Begin
Result := False;
GDSL := GetGDSLibrary;
GenerateDPB(
DB.Params, DPB, DPBLength);
// details zum ErrCode sind in der Unit IBErrorCodes
ErrCode :=
DB.Call(GDSL.isc_attach_database(StatusVector, Length(
DB.DatabaseName),
PChar(
DB.DatabaseName), @
DB.Handle,
DPBLength, PChar(DPB)), False);
if ErrCode = 0
then
Result := true;
end;
end.