Assistance to use Firebird with Devart driver

Discussion of open issues, suggestions and bugs regarding IBDAC (InterBase Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
BennieC
Posts: 11
Joined: Fri 11 Feb 2011 17:56

Assistance to use Firebird with Devart driver

Post by BennieC » Fri 11 Feb 2011 19:44

Hi, I have always used Interbase with DBExpress but now wish to use Firebird. I have installed FB and the Devart driver but do not know how to create a database (Firebird). Are there any Delphi examples/tutorials to show how to create a DB and connect to it using DBExpress, Firebird and DBXIda

Regards
\Bennie :?:

AndreyZ

Post by AndreyZ » Mon 14 Feb 2011 14:17

Hello,

Unfortunately you cannot create a database with the dbExpress driver. But you can use the IBDAC components to create a database using the TIBCConnection.CreateDatabase method.

To connect to the Firebird database using DbxIda you should use the following code:

Code: Select all

  SQLConnection.ConnectionName := 'Devart InterBase';
  SQLConnection.DriverName := 'DevartInterBase';
  SQLConnection.GetDriverFunc := 'getSQLDriverInterBase';
  SQLConnection.LibraryName := 'dbexpida.dll'; // or dbexpida30.dll, or dbexpida40.dll. Depends on IDE you are using.
  SQLConnection.VendorLib := 'fbclient.dll';
  SQLConnection.Params.Values['Database'] := 'your_database';
  SQLConnection.Params.Values['User_Name'] := 'your_user_name';
  SQLConnection.Params.Values['User_Name'] := 'your_password';
  SQLConnection.LoginPrompt := false;
  SQLConnection.Open;
For more information please read the DbxIda documentation.

BennieC
Posts: 11
Joined: Fri 11 Feb 2011 17:56

Post by BennieC » Wed 16 Feb 2011 06:26

Thanks for the assistance. I have used the TIBDatabase object to create a database, is this not good? While it has created it, and I managed to write and read data from it the flamerobin firebird manager can not connect to it, claiming unsupported on-disk structure for file. Was the file I created just an interbase db in disguise? What did you mean by IBDAC components?
Regards

AndreyZ

Post by AndreyZ » Thu 17 Feb 2011 08:23

You can find more information about the "unsupported on-disk structure" error here: http://www.firebirdfaq.org/faq80
IBDAC (InterBase Data Access Components) is our components for working with InterBase, Firebird, and Yaffil database servers. You can find more information about IBDAC here: http://www.devart.com/ibdac

BennieC
Posts: 11
Joined: Fri 11 Feb 2011 17:56

IBDAC DB Create

Post by BennieC » Fri 25 Feb 2011 09:57

Hi
I have purchased the IBDAC components but find no documentation regarding the DatabaseCreate function, especially to create a Firebird DB. Is there any help available. Do I have to use a component or can I call it directly, and if so, which dcu should I include?

I am developing an application whereby users could select which DB they want to use and have used DBExpress as the common channel. However, from what I read in your FAQ this may slow doen use on Firebird and Interbase. Would it be best to handle those databases through IBDAC?

Regards
Bennie

AndreyZ

Post by AndreyZ » Fri 25 Feb 2011 13:47

You can create a database using the TIBCConnection.CreateDatabase method. Here is an example of Firebird database creation:

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');
  IBCConnection.CreateDatabase;
With IBDAC you can connect only to InterBase, Firebird, and Yaffil database servers. If you want to work only with these database servers, it's better to use IBDAC. Mainly you will have the same performance with InterBase Data Access Components and dbExpress driver for InterBase and Firebird, because DbxIda uses IBDAC functionality.
If you want to connect to other database servers, you can use dbExpress drivers (http://www.devart.com/dbx), or our Universal Data Access Components. You can find more information about UniDAC here: http://www.devart.com/unidac

BennieC
Posts: 11
Joined: Fri 11 Feb 2011 17:56

Post by BennieC » Sun 27 Feb 2011 19:34

Hi
Thanks for the advice. I can create the database but when connecting to it, using the dbx I still get an unsupported on-disk structure problem. I assume that both these processes would use the same fbclient.dll. My connect process is as follows (following a create as you suggested using ibdac)

fDBCnx := TSQLConnection.Create(nil);
fDBCnx.DriverName := 'DevartInterbase';
fDBCnx.LibraryName := 'dbexpida40.dll';
fDBCnx.VendorLib := 'fbclient.dll';
fDBCnx.GetDriverFunc := 'getSQLDriverINTERBASE';
fDBCnx.Params.values['Database'] := IncludeTrailingPathDelimiter(fDBPath)
+ fDBName + '.fdb';
// Set the passwords
fDBCnx.LoginPrompt := false;
fDBCnx.Params.values['User_name'] := PRGMUSER;
fDBCnx.Params.values['Password'] := PRGMPASSWORD;
try
fDBCnx.open;
result := true;
except
on E: Exception do
begin
MessageDlg(fDBPath + fDBName + '.fdb' + #13 + #10 +
'Database connection failure - call system administrator. ' + #13
+ #10 + 'Error Message: ' + E.Message, mtWarning, [mbOK], 0);
exit;
end;
end;

Maybe you can spot the error - I seem to be missing it completely
regards
Bennie

AndreyZ

Post by AndreyZ » Mon 28 Feb 2011 13:28

It seems that you are using different fbclient.dll libraries for creating and accessing this database. Please check that you don't have any old fbclient.dll libraries. You can also try using the full path to the fbclient.dll library in the following way:

Code: Select all

IBCConnection.ClientLibrary := 'C:\Windows\System32\fbclient.dll';
fDBCnx.VendorLib := 'C:\Windows\System32\fbclient.dll';

BennieC
Posts: 11
Joined: Fri 11 Feb 2011 17:56

Post by BennieC » Sun 06 Mar 2011 15:58

Hi, I am afraid I still don't come right. Could you perhaps send me a working example of a create firebird db, connection to it and maybe a simple query. I assume that the component would have complained if the fb server was not running.
I have found that if I stop the interbase server but leave the Firebird, the connection complains about an unavailable database, even though it did apparently create the db. This is most confusing. Can one run firebird and interbase servers simultaneously.
Regards
Bennie

AndreyZ

Post by AndreyZ » Mon 07 Mar 2011 08:39

I've sent you an example by e-mail. You shouldn't run Firebird and Interbase simultaneously.

Post Reply