2

I have narrowed done my problem to small sample where this issue can be easily produced.

Brief - I am using embeded dll's of firebird for database connectivity i.e. fbembed.dll to connect to firebird databases. In code, i have three connection strings like this (note additional attribute client library specified in third connection string) -

private const string connection1 = @"User=SYSDBA;Password=masterkey;Database=D:\DB1.fdb;ServerType=1;Charset=UTF8";
private const string connection2 = @"User=SYSDBA;Password=masterkey;Database=D:\DB2.fdb;ServerType=1;Charset=UTF8";
private const string connection3 = @"User=SYSDBA;Password=masterkey;Database=D:\DB2.fdb;ServerType=1;client library=D:\fbembed.dll;Charset=UTF8";

I have two buttons on UI and on first button click i have this code -

FbConnection fbConnection = new FbConnection(connection1);
fbConnection.Open();

On second button click i have this code -

FbConnection fbConnection = new FbConnection(connection3);
fbConnection.Open();

If i create connection with connection string specified as connection3, i am getting FbException "operating system directive CreateFile failed".

However, if i replace the connection string as connection2, it works fine.

Moreover, if i create connection with connection3 and then with connection1 no issue but in case i create connection with connection1 and then connection3, same fbexception coming.

Note, the database specified in connection2 and connection3 is same but only difference is of additional attribute client library.

Why this strange behaviour with embeded firebird. It all works fine in case i have firebird server installed on my system. But, i want to know the issue why it persists in embeded dll's of firebird?

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
Rohit Vats
  • 79,502
  • 12
  • 161
  • 185
  • What is the entire error message? Last line should explain reason why CreateFile failed. – Marcodor Jul 18 '12 at 09:38
  • Error message says only "operating system directive CreateFile failed" with stack trace - at FirebirdSql.Data.FirebirdClient.FbConnectionInternal.Connect() at FirebirdSql.Data.FirebirdClient.FbConnectionPool.Create() at FirebirdSql.Data.FirebirdClient.FbConnectionPool.CheckOut() at FirebirdSql.Data.FirebirdClient.FbConnection.Open() – Rohit Vats Jul 18 '12 at 10:29
  • Inner excpetion stack trace - at FirebirdSql.Data.Client.Native.FesDatabase.ParseStatusVector(IntPtr[] statusVector) at FirebirdSql.Data.Client.Native.FesDatabase.Attach(DatabaseParameterBuffer dpb, String dataSource, Int32 port, String database) at FirebirdSql.Data.FirebirdClient.FbConnectionInternal.Connect() – Rohit Vats Jul 18 '12 at 10:29
  • Strange, "native" fb error is more explicit. Embeded fbembed.dll needs at least 3 dlls: icu*.dll. Are these dlls in the same folder where fbembed is located? – Marcodor Jul 18 '12 at 11:56
  • Yes they are located in the same folder. You can try it in sample application with the simple steps at your end too. This issue is fairly producible. – Rohit Vats Jul 18 '12 at 12:12
  • What version of Firebird do you use, 2.5 ? – Marcodor Jul 18 '12 at 12:13
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/14062/discussion-between-marcodor-and-rv1987) – Marcodor Jul 18 '12 at 12:14
  • Maybe this might help others: I can reproduce a similar error message for embedded server if I deny write access to the temp directory in Windows. – yonojoy Sep 09 '16 at 14:07

3 Answers3

3

Your issue is related to: http://tracker.firebirdsql.org/browse/CORE-2507

This is a bug in FB engine, fixed in 2.1.4 version.

Marcodor
  • 4,578
  • 1
  • 20
  • 24
  • But strange thing is when i create connection with string having client library specified in it and then goes for connection without client library, its working fine even when there is fb_pid.lck file exists in the %temp% folder. – Rohit Vats Jul 18 '12 at 18:07
  • +1 for this much help mate. As a workaround i have removed the client library from the second connection string but still keeping this opened since i would like to know what's causing this issue. Since .lck file theory should be applied other way round too but its not so i am guessing it is some other issue. – Rohit Vats Jul 18 '12 at 18:18
  • @RV1987 Best workarround is tu update your FB version at least to 2.1.4 or 2.5 – Marcodor Jul 18 '12 at 19:05
  • Thnks i tried it with embedded dll of 2.1.4 but issue still coming in it. However, this issue is fixed in version 2.5. Thanks a lot.. :) – Rohit Vats Jul 19 '12 at 07:20
0

The problem is that you are connecting to database with Firebird server and Firebird embeeded. The first one locks the database file for open with other proceses(i think you are using superserver).

Another option is that you are using two fbembed.dll from different locations.

  • No, in both connection string sever type is 1 which stands for Embedded type and moreover this issue is producible even if database names are different. – Rohit Vats Jul 18 '12 at 18:16
0

This is rather funny but I fixed my Firebird 1.5 + Windows 7 problem! Installed Firebird as application then ran fb application as admin and the batch file (gbak.exe -b -v -g) also as admin. Got rid of:

**ERROR**:uavailable database
or
operating system directive CreateFile failed
Dhara
  • 4,093
  • 2
  • 36
  • 69