File Lock Problems
Posted: 25.10.2007, 12:25
Hi,
I've coded these lines below to initialize a Firebird 2.x (embedded)
database for testing purposes.
The code does not make much sense but I it was my intention to show you
what happens in other procedures of my application before without copying
that code, too.
First I create a Firebird database and a query which fetches just a single
record. This works OK.
Afterwards I'm using the Zeos library to create a connection object with
exactly the same database (file). When connecting to the database I get an
error: "EZSQLException: SQL Error: operating system directive CreateFile
failed. The process cannot access the file since it is already used by
another process." (translated from German).
Why am I doing those steps you will ask? I'm using Context Database
Designer which can update an existing database using a given schema. This
component (from Contextsoft.com, btw.) uses TIBDatabase, too to access the
appropriate database.
So I've build a testing application which performs almost the same steps as
the component from Contextsoft, but I do get that mentioned error in both
cases.
Does sbdy have any clue what's happening here?
Thanks, Michael
I've coded these lines below to initialize a Firebird 2.x (embedded)
database for testing purposes.
The code does not make much sense but I it was my intention to show you
what happens in other procedures of my application before without copying
that code, too.
First I create a Firebird database and a query which fetches just a single
record. This works OK.
Afterwards I'm using the Zeos library to create a connection object with
exactly the same database (file). When connecting to the database I get an
error: "EZSQLException: SQL Error: operating system directive CreateFile
failed. The process cannot access the file since it is already used by
another process." (translated from German).
Why am I doing those steps you will ask? I'm using Context Database
Designer which can update an existing database using a given schema. This
component (from Contextsoft.com, btw.) uses TIBDatabase, too to access the
appropriate database.
So I've build a testing application which performs almost the same steps as
the component from Contextsoft, but I do get that mentioned error in both
cases.
Does sbdy have any clue what's happening here?
Code: Select all
function TWorkingDatabase.InitDatabase : boolean;
var
o : TIBDatabase;
q : TIBQuery;
begin
FDBVersion := '';
o := TIBDatabase.Create(Nil);
o.DatabaseName := DBPath;
o.Params.Add('password=12345678');
o.Params.Add('user_name=sysdba');
o.LoginPrompt := False;
o.Open;
q := TIBQuery.Create(nil);
q.Database := o;
q.SQL.Text := 'SELECT VERINFO FROM SysTable';
q.Transaction := o.DefaultTransaction;
if q.Transaction = nil then
q.Transaction := o.InternalTransaction;
q.Active := True;
q.Active := False;
o.ForceClose;
o.Connected := False;
dmMainDatabase.dbMainConnection.Database := DBPath;
dmMainDatabase.dbMainConnection.Protocol := DBProtocol;
dmMainDatabase.dbMainConnection.Password := 'abcdefghi';
dmMainDatabase.dbMainconnection.User := 'sysdba';
try
dmMainDatabase.dbMainConnection.Connected := True;
// Fetch db version
FDBVersion := dmMainDatabase.DatabaseSchema.VersionLabel;
Result := True;
finally
end;
end;