Author Topic: SQLite3Connection in Win10  (Read 372 times)

amalfine

  • Newbie
  • Posts: 2
SQLite3Connection in Win10
« on: October 27, 2026, 08:31:28 am »
Ciao to all
I have a little problem connecting SQLite3 to DB in Win 10. Program works fine in Linux but in Win 10
    SQLite3Connection.DatabaseName:='......';
doesn't works more. Something was changed and I don't find any documentation.
Somebody can tell me, please, how to connect DB?
Thanks
Amedeo

dsiders

  • Hero Member
  • *****
  • Posts: 1742
Re: SQLite3Connection in Win10
« Reply #1 on: October 27, 2026, 09:11:34 am »
Ciao to all
I have a little problem connecting SQLite3 to DB in Win 10. Program works fine in Linux but in Win 10
    SQLite3Connection.DatabaseName:='......';
doesn't works more. Something was changed and I don't find any documentation.
Somebody can tell me, please, how to connect DB?
Thanks
Amedeo

The thing that always gets me is having sqlite3 connected to the database when I start the Lazarus app. Close the database in the sqlite3 command line.

Other than that, is the file name (or path) correct? Does it have embedded spaces in the path (quote it)?

Zvoni

  • Hero Member
  • *****
  • Posts: 3605
Re: SQLite3Connection in Win10
« Reply #2 on: October 27, 2026, 09:22:25 am »
and sqlite3.dll is in the same folder as the project/executable?
the dll has the correct bitness of the compile-target?
Code: Pascal  [Select][+][-]
  1.  SQLite3Connection.DatabaseName:='MyDatabase.db3';
expects the Database in the same folder as the project/executable

I've been working with Lazarus with Sqlite on Win10/11 for years now, and NEVER had an issue
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

amalfine

  • Newbie
  • Posts: 2
Re: SQLite3Connection in Win10
« Reply #3 on: October 27, 2026, 04:34:08 pm »
Thanks for the aswers.
I solved with DB in the same directory of executable but it's not my prefered solution. For now it's ok.
Thanks again
Amedeo

JanRoza

  • Hero Member
  • *****
  • Posts: 758
    • http://www.silentwings.nl
Re: SQLite3Connection in Win10
« Reply #4 on: October 27, 2026, 05:12:40 pm »
If the database is in another directory, then why not add the correct path to the database name?
OS: Windows 11 / Linux Mint 22.3
       Lazarus 4.8 RC FPC 3.2.2
       CodeTyphon 9.1 FPC 3.3.1

Zvoni

  • Hero Member
  • *****
  • Posts: 3605
Re: SQLite3Connection in Win10
« Reply #5 on: October 28, 2026, 08:48:38 am »
Thanks for the aswers.
I solved with DB in the same directory of executable but it's not my prefered solution. For now it's ok.
Thanks again
Amedeo
If the database is in another directory, then why not add the correct path to the database name?

Correct.

Code: Pascal  [Select][+][-]
  1. SQLite3Connection.DatabaseName:='Database'+DirectorySeparator +'MyDatabase.db3';  //Subfolder "Database" beneath executable-Folder
  2. SQLite3Connection.DatabaseName:=Application.Location+'Database'+DirectorySeparator +'MyDatabase.db3';  //Fully qualified Path to Subfolder "Database" --> preferable way. Not reliable on MacOS. Could also use ParamStr(0) instead
  3.  

Note: Special care has to be taken into account, if your App lies on a OneDrive/Sharepoint
Have a guess why....
« Last Edit: October 28, 2026, 08:50:16 am by Zvoni »
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

 

TinyPortal © 2005-2018