Beginner's question regarding DB create

Beginner's question regarding DB create

Postby BennieC » Tue 24 Jan 2012 13:29

I would like to programmatically create a Firebird DB. I found that I need to have an existing DB and can then use SQL to create the DB. I created an initial DB using FlameRobin, but cannot connect to it using DBExpress. I use Delphi XE and FB 2.5.1

Code: Select all

procedure TFirebirdDB.CreateFireBDB;
// This procedure connects to a default DB and then uses SQL to create a DB
var
  TmpCnx : TSQLConnection;
begin
    TmpCnx := TSQLConnection.Create(nil);
    TmpCnx.DriverName := 'DevartInterbase';
    TmpCnx.LibraryName := 'dbexpida40.dll';
    TmpCnx.VendorLib := 'C:\Windows\System32\fbclient.dll';
    TmpCnx.GetDriverFunc := 'getSQLDriverINTERBASE';
    TmpCnx.Params.values['Database'] := IncludeTrailingPathDelimiter(fDBPath)
                                        + 'MASTER.fdb';
  // Set the passwords
    TmpCnx.LoginPrompt := false;
    TmpCnx.Params.values['User_name'] := fmyUser;
    TmpCnx.Params.values['Password'] := fmyPassword;
    try
      TmpCnx.open;
    except
      on E: Exception do
      begin
        MessageDlg(fDBPath + fDBName + '.fdb' + #13 + #10 +
          'Master DB connection failure - call system administrator. ' + #13
          + #10 + 'Error Message: ' + E.Message, mtWarning, [mbOK], 0);
        exit;
      end;
    end;
end;

Can someone show me what is wrong with the code. It complains about
"Unsupported on-disk structure for file ...\MASTER.FDB; found 32779, support 13
BennieC
 
Posts: 11
Joined: Fri 11 Feb 2011 17:56

Postby AndreyZ » Tue 24 Jan 2012 14:49

Hello,

This problem occurs if you use the incorrect client library. To solve the problem, you should use the same client library that FlameRobin used to create the MASTER.fdb database. For more information, please read the following article: http://www.firebirdfaq.org/faq80
AndreyZ
 

Postby BennieC » Wed 25 Jan 2012 11:39

I made sure only one fbserver is running, but it is set to run on port 3051.
I created a db on FlameRobin and cannot read it with the code as shown before. Where am i going wrong?
BennieC
 
Posts: 11
Joined: Fri 11 Feb 2011 17:56

Postby AndreyZ » Thu 26 Jan 2012 08:47

The problem is that client library (fbclient.dll) that you are using is not the same that was used to create your database by FlameRobin. To solve the problem, you should create your database and access it using the same client library. Please check that there is no other fbclient.dll or gds32.dll (FlameRobin could use it) libraries except the ones in the System32 and Firebird_Install_Directory directories.
Also, you should include the 3051 port into the Database connection param. Here is an example:
Code: Select all
TmpCnx.Params.Values['Database'] := 'localhost/3051:' + IncludeTrailingPathDelimiter(fDBPath) + 'MASTER.fdb';
AndreyZ
 


Return to dbExpress driver for InterBase & Firebird