Got this working for SQLServer and embedded FB but I just can't figure out how to do this for a Firebird Server..
With the embedded version you can just check FileExists with SQLServer you can connect with no DB and use GetDatabaseNames, but how do you do this for Firebird?
Any help appreciated..
How to create a Firebird db on Server if not exists?
Re: How to create a Firebird db on Server if not exists?
You can create a database using the TIBCConnection.CreateDatabase method. Here is an example of Firebird database creation in case when no DB file exists:
Code: Select all
IBCConnection.Database := 'database_name.fdb';
IBCConnection.ClientLibrary := 'fbclient.dll';
IBCConnection.Params.Clear;
IBCConnection.Params.Add('USER ''SYSDBA''');
IBCConnection.Params.Add('PASSWORD ''masterkey''');
IBCConnection.Params.Add('PAGE_SIZE 4096');
IBCConnection.Params.Add('DEFAULT CHARACTER SET WIN1251');
try
IBCConnection.Connect;
ShowMessage('Connect DB');
except
on E : Exception do
if Pos('The system cannot find the file specified.', E.Message) <> 0 then
begin
IBCConnection.CreateDatabase;
ShowMessage('Create DB');
end;
end;
Re: How to create a Firebird db on Server if not exists?
I am already able to create the db both on server and embedded with UniConnection, but this is what I was missing, thanks.
ViktorV wrote: try
IBCConnection.Connect;
ShowMessage('Connect DB');
except
on E : Exception do
if Pos('The system cannot find the file specified.', E.Message) <> 0 then
begin
IBCConnection.CreateDatabase;
ShowMessage('Create DB');
end;
end;
[/code]
Re: How to create a Firebird db on Server if not exists?
Feel free to contact us if you have any further questions about our product.