Recent

Author Topic: Not able to make a connection to a database  (Read 1907 times)

Adri

  • New Member
  • *
  • Posts: 25
Not able to make a connection to a database
« on: August 23, 2025, 06:01:09 pm »
I am trying to make an application with a database. For that, I would like to use an SQLite3 database.   :)

To start learning the technique I started with 'https://wiki.freepascal.org/SQLite'. There I read: "All drivers do need the SQLite library/dll in the executable directory", so I copied the 'sqlite3.dll' file into the same directory where my Pascal/Lazarus source and other files are.

Next I continued wth the information as given in 'https://wiki.freepascal.org/SQLdb_Tutorial1'. All goes well until I reach the point where it says: "Now check if all settings so far are correct: set the 'Connected' property to 'True'. If the database path isn't correct or if username or password are wrong, you will get an error message. If the connection was successful, you should cut it now (set 'Connected' to 'False')."

At that moment there wil a message show: "Can not load SQLite client library "sqlite3.dll". Check your installation".   :o
After checking I can not think of what I am doing wrong here...   :(

Can anyone help?   :-\

dseligo

  • Hero Member
  • *****
  • Posts: 1682
Re: Not able to make a connection to a database
« Reply #1 on: August 23, 2025, 06:13:05 pm »
You have two things to consider.
1. Connection from your program (runtime) and connection from Lazarus (design time): you are trying to access at design time, so you need to put dll in Lazarus' directory as well
2. Bitness of dll. You have to match bitness to your program and to Lazarus (if you use design time access to SQlite). So if Lazarus is 64 bit, you need to put 64 bit dll in Lazarus directory and if you compile your application in 32 bit, you need to put 32 bit dll in your application directory.

Adri

  • New Member
  • *
  • Posts: 25
Re: Not able to make a connection to a database
« Reply #2 on: August 23, 2025, 06:41:59 pm »
Dseligo,

Many thanks, your number one hit it!      ;)
I copied the 'sqlite3.dll' file into '..\Lazarus' and now it wordks (at designtime....).
Should have thought of that myself....    :-\ 

egsuh

  • Hero Member
  • *****
  • Posts: 1777
Re: Not able to make a connection to a database
« Reply #3 on: August 24, 2025, 09:10:02 am »
I prefer to put the sqlite.dll file at windows\system32 directory, in the case of 64 bit Windows.

 

TinyPortal © 2005-2018