Page 1 of 1

howto open firebird database exclusive

Posted: Mon 15 Aug 2011 19:29
by scola
How can I open a firebird database with ibdac in order to add new fields or tables?

Posted: Tue 16 Aug 2011 08:31
by AlexP
There are no special methods to create database objects (tables, fields, etc.) in IBDAC, that's why you should use DDL operators.

You can use the following code to add fields to the table:

Code: Select all

var
  IBCConnection: TIBCConnection;
begin
  IBCConnection := TIBCConnection.Create(nil);
  IBCConnection.Username := 'LOGIN';
  IBCConnection.Password := 'PASSWORD';
  IBCConnection.Server := 'SERVER';
  IBCConnection.Database := 'D:\Path\To\Data\TEST.FDB';
  IBCConnection.Connect;
  IBCConnection.ExecSQL('ALTER TABLE TEST ADD NEW_FIELD SMALLINT',[]);

Posted: Tue 16 Aug 2011 09:23
by scola
Thats what I'm doing, but I get an error, if other users are connected to the database. Therefore I need to open the database exclusive in order to allow firebird to update metadata.

Posted: Tue 16 Aug 2011 12:14
by AlexP
Hello,

This problem is connected with the Firebird server specifics and cannot be solved with the help of our or any other components.
You can read FAQ concerning exclusive access at http://www.firebirdfaq.org/faq131/.

Posted: Tue 16 Aug 2011 17:27
by scola
Thanks