Problem to connect to database more than one

72 views
Skip to first unread message

gkvi...@gmail.com

unread,
Jun 13, 2024, 4:24:20 AMJun 13
to firebird-support
I have problem to connect to a database with more than one program.

I figured out that the problem are the connection path. For example the employee database
C:\Program Files\Firebird\Firebird_3_0\examples\empbuild\EMPLOYEE.FDB

the follow path are also correct on a german windows
C:\Programme\Firebird\Firebird_3_0\examples\empbuild\EMPLOYEE.FDB

the difference are "Program Files" and "Programme", the same could be also on different localizations of windows.

But when you try to connect once with the path "Program Files" and the other program try it with "Programme" the follow error occures.

I/O error during "CreateFile (open)" operation for file "C:\PROGRAMME\FIREBIRD\FIREBIRD_3_0\EXAMPLES\EMPBUILD\EMPLOYEE.FDB".
Error while trying to open file.
Der Prozess kann nicht auf die Datei zugreifen, da sie von einem anderen Prozess verwendet wird. .

SQL Code: -902
IB Error Number: 335544344

The problem is i have two programs, one is a Desktop program and the other are a windows service. Both Program use the function ParamStr(0) in Delphi 12.1.1 to get the application name. My database are at the same location.

ParamStr(0) delivers "Programme" in the windows-Service
ParamStr(0) delivers "Program Files" in the Desktop program

I know, you can say the problem are at the function ParamStr(0). But i think Firebird should also not have a problem when you try to open the same database, but with other path name.



Dimitry Sibiryakov

unread,
Jun 13, 2024, 5:28:46 AMJun 13
to firebird...@googlegroups.com
gkvi...@gmail.com wrote 13.06.2024 10:24:
> I know, you can say the problem are at the function ParamStr(0).

No, the problem is that you uses embedded mode to connect to the database.
Change connection string to use "inet" or "xnet" protocol as described in
documentation.

https://firebirdsql.org/file/documentation/html/en/firebirddocs/qsg5/firebird-5-quickstartguide.html#qsg5-databases-connstrings

--
WBR, SD.

gkvi...@gmail.com

unread,
Jun 13, 2024, 12:00:48 PMJun 13
to firebird-support
Could you explain a little bit more? Follow the code i use in Delphi

Port := 3050;
Server := 'localhost';
Database := ChangeFileExt(ParamStr(0), '.FDB');

fdConnection.Params.Clear;
oParams := TStringList.Create;
oParams.Add('Protocol=TCPIP');
oParams.Add(Format('Server=%s', [Server]));
oParams.Add(Format('Database=%s', [Database]));
oParams.Add(Format('Port=%d', [Port]));
oParams.Add(Format('User_Name=%s', ['SYSDBA']));
oParams.Add(Format('Password=%s', ['masterkey']));
oParams.Add(Format('CharacterSet=%s', ['UTF8']));
oParams.Add('Pooled=True');

AddMsg('Config FireDAC');
FOR VAR i := 0 TO oParams.Count - 1 DO BEGIN
  AddMsg('oParams: ' + oParams[i]);
END;
fdcConnectionName := 'FB_myAppname';
FDManager.AddConnectionDef(fdcConnectionName, 'FB', oParams);
FDManager.WaitCursor := gcrNone;
FDManager.Active := True;
fdConnection.ConnectionDefName := fdcConnectionName;

I am of the opinion that FireDac does not use the embedded mode, or am I seeing it wrong?

The embedded mode was my first thought too. Now I have set the path in the shortcut to start the desktop program to the same path as the service was registered. Now it works as desired. So ParamStr(0) returns the same path in both cases.

Dimitry Sibiryakov

unread,
Jun 13, 2024, 12:21:20 PMJun 13
to firebird...@googlegroups.com
gkvi...@gmail.com wrote 13.06.2024 18:00:
> I am of the opinion that FireDac does not use the embedded mode, or am I seeing
> it wrong?

You should read the documentation which link I gave. I have no idea how
FireDAC convert database parameters into connection string but most likely you
can find it out using debugger. Then check connection string that arrives to
Firebird client library.

--
WBR, SD.

gkvi...@gmail.com

unread,
Jun 14, 2024, 4:07:16 AMJun 14
to firebird-support
OK, I found out that Firedac does not add xnet to the connection string.

Adjusted it accordingly, now the following connection string is used
'xnet://localhost/3050:C:\Program Files\Firebird\Firebird_3_0\examples\empbuild\EMPLOYEE.FDB'

but when i try to open a second connection with
'xnet://localhost/3050:C:\Programme\Firebird\Firebird_3_0\examples\empbuild\EMPLOYEE.FDB'

i got the same error

Mark Rotteveel

unread,
Jun 14, 2024, 4:10:49 AMJun 14
to firebird...@googlegroups.com
On 14/06/2024 10:07, gkvi...@gmail.com wrote:
> OK, I found out that Firedac does not add xnet to the connection string.
>
> Adjusted it accordingly, now the following connection string is used
> 'xnet://localhost/3050:C:\Program
> Files\Firebird\Firebird_3_0\examples\empbuild\EMPLOYEE.FDB'
>
> but when i try to open a second connection with
> 'xnet://localhost/3050:C:\Programme\Firebird\Firebird_3_0\examples\empbuild\EMPLOYEE.FDB'
>
> i got the same error

That is not a valid connection string for XNET. You need to use

xnet://C:\Program Files\Firebird\Firebird_3_0\examples\empbuild\EMPLOYEE.FDB
xnet://C:\Programme\Firebird\Firebird_3_0\examples\empbuild\EMPLOYEE.FDB

That said, the way Firebird normalizes file paths on Windows is - in my
opinion - antiquated and extremely brittle, so I wouldn't be surprised
if it simply doesn't work correctly for this case.

Mark
--
Mark Rotteveel

Mark Rotteveel

unread,
Jun 14, 2024, 4:12:25 AMJun 14
to 'Mark Rotteveel' via firebird-support
On 14/06/2024 10:10, 'Mark Rotteveel' via firebird-support wrote:
> On 14/06/2024 10:07, gkvi...@gmail.com wrote:
>> OK, I found out that Firedac does not add xnet to the connection string.
>>
>> Adjusted it accordingly, now the following connection string is used
>> 'xnet://localhost/3050:C:\Program
>> Files\Firebird\Firebird_3_0\examples\empbuild\EMPLOYEE.FDB'
>>
>> but when i try to open a second connection with
>> 'xnet://localhost/3050:C:\Programme\Firebird\Firebird_3_0\examples\empbuild\EMPLOYEE.FDB'
>>
>> i got the same error
>
> That is not a valid connection string for XNET. You need to use
>
> xnet://C:\Program
> Files\Firebird\Firebird_3_0\examples\empbuild\EMPLOYEE.FDB
> xnet://C:\Programme\Firebird\Firebird_3_0\examples\empbuild\EMPLOYEE.FDB

Or alternatively, you need to use the INET protocol:

inet://localhost:3050/C:\Program
Files\Firebird\Firebird_3_0\examples\empbuild\EMPLOYEE.FDB
inet://localhost:3050/C:\Programme\Firebird\Firebird_3_0\examples\empbuild\EMPLOYEE.FDB


Observe the use of localhost:3050/ instead of localhost/3050: (!)

Mark
--
Mark Rotteveel

gkvi...@gmail.com

unread,
Jun 14, 2024, 4:18:39 AMJun 14
to firebird-support
Ok thanks,

I stumbled across the problem by chance because I manually registered a Windows service for a customer. And of course I used the "German" spelling as usual, but the installation program and also when you select the path via a browser window then sets the "English" path.

gkvi...@gmail.com

unread,
Jun 14, 2024, 4:30:24 AMJun 14
to firebird-support
xnet://C:\Program Files\Firebird\Firebird_3_0\examples\empbuild\EMPLOYEE.FDB
xnet://C:\Programme\Firebird\Firebird_3_0\examples\empbuild\EMPLOYEE.FDB

does not work either


gkvi...@gmail.com

unread,
Jun 14, 2024, 4:34:54 AMJun 14
to firebird-support
Basically it's not a problem, you just have to pay attention to the spelling. If you don't know, you can spend a lot of time trying to find the mistake.

And since there are a lot of Windows installations that are not in English, I'm surprised that it hasn't been noticed yet.

Karol Bieniaszewski

unread,
Jun 14, 2024, 4:45:13 AMJun 14
to firebird...@googlegroups.com

I do not see orginal message, but if it is about Firedac it is simple.

Double click on FDConnection, choose driver FB.

And then look at

PROTOCOL. Change it to TCPIP

, setup Server to e.g. 127.0.0.1

and Port to e.g. 3050,

Database to e.g. C:\mydb\fbdb.fdb

User to e.g. SYSDBA

Password to e.g. masterkey

 

Look also at Rolename.

 

After that you should have in FDConnection1.Params:

 

Protocol=TCPIP

Database=C:\mydb\fbdb.fdb

User_Name=SYSDBA

Password=masterkey

Server=127.0.0.1

Port=3050

CharacterSet=WIN1250

DriverID=FB

 

Regards,

Karol Bieniaszewski

--

You received this message because you are subscribed to the Google Groups "firebird-support" group.

To unsubscribe from this group and stop receiving emails from it, send an email to firebird-suppo...@googlegroups.com.

To view this discussion on the web, visit https://groups.google.com/d/msgid/firebird-support/2fa8618f-facb-4450-ad43-b1cb0cd06241%40lawinegevaar.nl.

 

Reply all
Reply to author
Forward
0 new messages