Author Topic: [Solved[ How to define the SQLite3.DLL path for the SQLConnect ?  (Read 367 times)

jamie

  • Hero Member
  • *****
  • Posts: 7937
At app startup, I need to define the path to the DLL for the Sqlite3 before the SQLite components open a database.

CUrrently the DLL is located in the project path which is fine however, this project is going to be 32/64 bit, and I need to have it point to the correct DLL on startup! I will have these DLLs loaded in their own folders, one for 64 and the other for 32 bits.

I did see a function that looks like it could be it in the SQLConn unit, but I can't be sure of that.

I suppose I could have the 2 EXE's also in a separate folder within the project but that would cause another issue.


Any thoughts?

Jamie
« Last Edit: August 11, 2026, 02:52:34 am by jamie »
The only true wisdom is knowing you know nothing

dsiders

  • Hero Member
  • *****
  • Posts: 1692
Re: How to define the SQLite3.DLL path for the SQLConnect ?
« Reply #1 on: August 10, 2026, 01:10:23 am »
At app startup, I need to define the path to the DLL for the Sqlite3 before the SQLite components open a database.

CUrrently the DLL is located in the project path which is fine however, this project is going to be 32/64 bit, and I need to have it point to the correct DLL on startup! I will have these DLLs loaded in their own folders, one for 64 and the other for 32 bits.

Sounds like youi're trying to reinvent TSQLDBLibraryLoader. Check out the example in https://gitlab.com/freepascal.org/fpc/source/-/blob/main/packages/fcl-db/examples/sqlite3loadlib.lpr?ref_type=heads.

jamie

  • Hero Member
  • *****
  • Posts: 7937
Re: How to define the SQLite3.DLL path for the SQLConnect ?
« Reply #2 on: August 10, 2026, 01:26:49 am »
I'll study that and see if I can get that working with the existing code I have. I am using the components from the palette, and I see that is not the same there, I need to intercept the LIBRARY load path, but I can study the sources.


Thanks

Jamie
The only true wisdom is knowing you know nothing

jamie

  • Hero Member
  • *****
  • Posts: 7937
Re: How to define the SQLite3.DLL path for the SQLConnect ?
« Reply #3 on: August 11, 2026, 02:33:13 am »
This is what I am doing since I already have a Data Module in place with the needed components.

Code: Pascal  [Select][+][-]
  1. procedure TDataMM.SQLConnector1BeforeConnect(Sender: TObject);
  2. begin
  3. {$IFDEF CPU32}
  4.  SQLite3Conn.SQLiteLibraryName :='32bitdata\sqlite3.dll';
  5. {$ELSE}
  6.  SQlite3Conn.SQLiteLibraryName := '64bitdata\sqlite3.dll';
  7. {$IFEND}
  8. end;                                      
  9.  

If I decide to do the ARM64 later, which maybe an undertaking I can alter this. Ect.

Jamie
The only true wisdom is knowing you know nothing

Mike.Cornflake

  • Hero Member
  • *****
  • Posts: 1319
Re: [Solved[ How to define the SQLite3.DLL path for the SQLConnect ?
« Reply #4 on: August 11, 2026, 03:42:11 pm »
Code: Pascal  [Select][+][-]
  1. procedure TDataMM.SQLConnector1BeforeConnect(Sender: TObject);
  2. begin
  3. {$IFDEF CPU32}
  4.  SQLite3Conn.SQLiteLibraryName :='32bitdata\sqlite3.dll';
  5. {$ELSE}
  6.  SQlite3Conn.SQLiteLibraryName := '64bitdata\sqlite3.dll';
  7. {$IFEND}
  8. end;                                      
  9.  

Nice.  Many thanks for sharing
Lazarus Trunk/FPC latest fixes on Windows 11
  How to use the forum:  https://wiki.lazarus.freepascal.org/Forum

 

TinyPortal © 2005-2018