Recent

Author Topic: [solved] Error openning Database  (Read 6798 times)

DeBritto

  • Jr. Member
  • **
  • Posts: 68
[solved] Error openning Database
« on: December 17, 2017, 07:34:30 pm »
Hi Folks,
I'm using this routine to connect to a database (SQLdb + Firebird 3.0):

Code: Pascal  [Select][+][-]
  1. // Local Server
  2. IBConnection_ConnSmCube.DatabaseName:= GetCurrentDirUTF8 + DirectorySeparator + 'SMCUBE.FDB';
  3. IBConnection_ConnSmCube.UserName:= 'SYSDBA';
  4. IBConnection_ConnSmCube.Password:= 'masterkey';
  5. IBConnection_ConnSmCube.HostName:= ''; //'localhost';
  6. IBConnection_ConnSmCube.CharSet := 'UTF8';
  7. IBConnection_ConnSmCube.Dialect := 3;
  8. IBConnection_ConnSmCube.Transaction:= SQLTransaction_ConnSmCube;
  9. IBConnection_ConnSmCube.Transaction.Params.Text:='isc_tpb_read_committed'; // Allow me to see all commited data
  10.  
  11. try
  12.   IBConnection_ConnSmCube.Connected:= True;
  13. except
  14.   ShowMessage('Connection Failed!');
  15.   Application.Terminate;
  16. end;
  17. // Activate Transaction Compoment
  18. SQLTransaction_ConnSmCube.DataBase:= IBConnection_ConnSmCube;
  19. SQLTransaction_ConnSmCube.Active:= True;

The problem is that I cannot open the database if it is already open by another program:
Code: Pascal  [Select][+][-]
  1. IBCOnnection_ConnSmCube: DoInternalConnect:
  2. -I/O error during "CreateFile (open)" operation for file "C:\USERS\CHRISTIAN\ONEDRIVE\PUBLIC\SMCUBE.FDB"
  3. - Error while trying to open file- The file is already in use by another process.

What am I doing wrong?
Best regards
« Last Edit: December 18, 2017, 07:09:08 pm by DeBritto »

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: Error openning Database
« Reply #1 on: December 17, 2017, 11:37:12 pm »
Quote
Starting with Firebird 2.5, Firebird Embedded on Windows behaves like the SuperClassic server model, which means it uses shared access to the database files, and that the same database can be accessed by multiple Firebird Embedded applications and Firebird servers in the Classic or SuperClassic server model (but not SuperServer) if they are running on the same machine. The downside of this change is that embedded applications need to be able to create, read and write the shared database lockfiles (in C:\ProgramData\Firebird).
source https://stackoverflow.com/questions/32902746/connect-from-multiple-applicatons-to-one-firebird-database-via-embedded-dll

Starting with firebird 3 the embedded dll and fbclient dll where merged in to one dll the connection properties you shown will trigger the embedded mode.
« Last Edit: December 17, 2017, 11:39:00 pm by taazz »
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

rvk

  • Hero Member
  • *****
  • Posts: 6111
Re: Error openning Database
« Reply #2 on: December 17, 2017, 11:58:30 pm »
And using a database directly in a directory on ONEDRIVE might also be a bad idea. It's asking for trouble.


DeBritto

  • Jr. Member
  • **
  • Posts: 68
Re: Error openning Database
« Reply #3 on: December 18, 2017, 07:08:41 pm »
Hi,
Thank you Taazz, It's working now. I changed "c:/program Files/Firebird" permissions ;)

Thanks for the tip rvk

Best regards

 

TinyPortal © 2005-2018