Delphi & Firebird and Create Database
Posted: 22.04.2012, 18:41
Hi guys,
tried searching through the forum and other places but havewnt been able to answer this questions.
I'm trying to connect to a Firebird (32bit) database through ZeosLib.
Basic code looks like this (notice the commented code);
Is there a way to determine if the db already exists on the remote firebird server? (im testing locally, but plan to run software on remote server). Or is there perhaps a syntac for the above CreateNewDatabase parameter, that will allow it to check for the existing db before trying to create it.
Version used:
Firebird 2.5
Delphi XE
zeoslib from svn trunk/source
Many thanks for your replies / help
dve83
tried searching through the forum and other places but havewnt been able to answer this questions.
I'm trying to connect to a Firebird (32bit) database through ZeosLib.
Basic code looks like this (notice the commented code);
If the database does not exists, and i uncomment the above code (to create the db), all works fine. If I keep it like that and then compile again, the app tries to create an already existing database and gives me the following error (does receive a database handle from the function isc_dsql_execute_immediate).procedure TForm1.FormCreate(Sender: TObject);
begin
ZConnection1.Database := 'c:\test.fdb';
ZConnection1.Protocol := 'firebird-2.5';
ZConnection1.User := 'SYSDBA';
ZConnection1.Password := 'masterkey';
{ ZConnection1.Properties.Add ('CreateNewDatabase=CREATE DATABASE ' +
QuotedStr ('c:\test.fdb') + ' USER ' +
QuotedStr ('sysdba') + ' PASSWORD ' + QuotedStr ('masterkey') +
' PAGE_SIZE 4096 DEFAULT CHARACTER SET ISO8859_1');}
ZConnection1.Connect;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
ZConnection1.Disconnect;
end;
I can see that the db creation fails the second time around and that I dont receive a db handle. This raises the exception.---------------------------
ptest
---------------------------
SQL Error: invalid database handle (no active connection). Error Code: -904. Unsuccessful execution caused by an unavailable resource. The SQL: CREATE DATABASE 'c:\test.fdb' USER 'sysdba' PASSWORD 'masterkey' PAGE_SIZE 4096 DEFAULT CHARACTER SET ISO8859_1;
---------------------------
OK
---------------------------
Is there a way to determine if the db already exists on the remote firebird server? (im testing locally, but plan to run software on remote server). Or is there perhaps a syntac for the above CreateNewDatabase parameter, that will allow it to check for the existing db before trying to create it.
Version used:
Firebird 2.5
Delphi XE
zeoslib from svn trunk/source
Many thanks for your replies / help
dve83