Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2013-10

SqlDB fails under Windows to create a new Firebird database

5 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Graeme Geldenhuys

Hi,

I created a very simple little application that takes 2 parameters, then creates a empty FDB (firebird) database, then runs 4 script files to populate the database with default tables and data.

This little console application works perfectly under Linux and FreeBSD, but fails under Windows. Currently testing with Win2000 (32-bit).

Here is the code that causes the AV.

-----------------------

procedure TMyApplication.CreateEmptyDatabase;
var
  LHost: string;
  LDBName: string;
  n: integer;
begin
  n := Pos(':', FDBLocation);
  LHost   := Copy(FDBLocation, 1, n-1);
  LDBName := Copy(FDBLocation, n+1, Length(FDBLocation)-n);
  conn := TIBConnection.Create(self);
  conn.Dialect := 3;
  conn.HostName := LHost;
  conn.DatabaseName := LDBName;
  conn.UserName := 'sysdba';
  conn.Password := 'masterkey';
  writeln('Creating database... ', conn.HostName + ':' +
conn.DatabaseName);
  conn.CreateDB;
  conn.Connected := True;  // <<-------   This causes the AV under
Windows
end;
-----------------------

Here is the console output of when I run the program.

-----------------------

c:\programming\m2_system\Scripts>makedb -d
'127.0.0.1:c:\programming\data\m2_dl_3019.fdb'
Creating database... '127.0.0.1:c:\programming\data\m2_dl_3019.fdb' exception at 00431BD8:
: CreateDB :
-I/O error during "open" operation for file ""
-database or file exists.
-----------------------

I'm using FPC 2.6.2 32-bit on Windows 2000. Any clues what is wrong? And why does this code work on Linux and FreeBSD. Also, even though the error mentions the fact that the "database or file exits", that is definitely NOT true. There is no existing *.fdb file.

Regards,
- Graeme -

Graeme Geldenhuys
Show quoted text 16 lines
Here is the console output of when I run the program. ----------------------- c:\programming\m2_system\Scripts>makedb -d '127.0.0.1:c:\programming\data\m2_dl_3019.fdb' Creating database... '127.0.0.1:c:\programming\data\m2_dl_3019.fdb' exception at 00431BD8: : CreateDB : -I/O error during "open" operation for file "" -database or file exists. -----------------------

Ah, found the problem. In Windows it seems you mustn't wrap the -d command line parameter value with quotes. Removing the single quotes in the above command line fixed the problem. Linux and FreeBSD didn't mind the quoted string value.

------------------------

c:\programming\m2_system\Scripts>makedb -d
127.0.0.1:c:\programming\data\m2_dl_3019.fdb
Creating database... 127.0.0.1:c:\programming\data\m2_dl_3019.fdb running... create_firebird.sql
running... views.sql
running... rights.sql
running... defaults.sql
------------------------

I haven't tested what happens if you specify a path under Windows that contain spaces, but will test it later. I would imagine quotes must be used, but not sure how yet.

Regards,
Graeme

Michael Van Canneyt
to Graeme Geldenhuys: I created a very simple little application that takes 2 parameters, then creates a empty…
Graeme Geldenhuys wrote 44 lines
Hi, I created a very simple little application that takes 2 parameters, then creates a empty FDB (firebird) database, then runs 4 script files to populate the database with default tables and data. This little console application works perfectly under Linux and FreeBSD, but fails under Windows. Currently testing with Win2000 (32-bit). Here is the code that causes the AV. ----------------------- procedure TMyApplication.CreateEmptyDatabase; var   LHost: string;   LDBName: string;   n: integer; begin   n := Pos(':', FDBLocation);   LHost   := Copy(FDBLocation, 1, n-1);   LDBName := Copy(FDBLocation, n+1, Length(FDBLocation)-n);   conn := TIBConnection.Create(self);   conn.Dialect := 3;   conn.HostName := LHost;   conn.DatabaseName := LDBName;   conn.UserName := 'sysdba';   conn.Password := 'masterkey';   writeln('Creating database... ', conn.HostName + ':' + conn.DatabaseName);   conn.CreateDB;   conn.Connected := True;  // <<-------   This causes the AV under Windows end; ----------------------- Here is the console output of when I run the program. ----------------------- c:\programming\m2_system\Scripts>makedb -d '127.0.0.1:c:\programming\data\m2_dl_3019.fdb' Creating database... '127.0.0.1:c:\programming\data\m2_dl_3019.fdb' exception at 00431BD8:  : CreateDB :  -I/O error during "open" operation for file ""  -database or file exists. -----------------------

That is an interbase error. It clearly states what the problem is :)

However, it is strange that the CreateDB() does not catch this error.

Michael.

waldo kitty
to Graeme Geldenhuys: I created a very simple little application that takes 2 parameters, then creates a empty…
Graeme Geldenhuys wrote 16 lines
Here is the console output of when I run the program. ----------------------- c:\programming\m2_system\Scripts>makedb -d '127.0.0.1:c:\programming\data\m2_dl_3019.fdb' Creating database... '127.0.0.1:c:\programming\data\m2_dl_3019.fdb' exception at 00431BD8: : CreateDB : -I/O error during "open" operation for file "" -database or file exists. ----------------------- I'm using FPC 2.6.2 32-bit on Windows 2000. Any clues what is wrong? And why does this code work on Linux and FreeBSD. Also, even though the error mentions the fact that the "database or file exits", that is definitely NOT true. There is no existing *.fdb file.

what happens if you leave the drive designation (c:) out?

NOTE: No off-list assistance is given without prior approval. Please keep mailing list traffic on the list unless private contact is specifically requested and granted.