howto open firebird database exclusive

Discussion of open issues, suggestions and bugs regarding IBDAC (InterBase Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
scola
Posts: 3
Joined: Mon 15 Aug 2011 19:23

howto open firebird database exclusive

Post by scola » Mon 15 Aug 2011 19:29

How can I open a firebird database with ibdac in order to add new fields or tables?

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Post by AlexP » Tue 16 Aug 2011 08:31

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',[]);

scola
Posts: 3
Joined: Mon 15 Aug 2011 19:23

Post by scola » Tue 16 Aug 2011 09:23

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.

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Post by AlexP » Tue 16 Aug 2011 12:14

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/.

scola
Posts: 3
Joined: Mon 15 Aug 2011 19:23

Post by scola » Tue 16 Aug 2011 17:27

Thanks

Post Reply