Recent

Author Topic: cannot load sqlite3.dll  (Read 2801 times)

steveinalabama

  • New Member
  • *
  • Posts: 40
cannot load sqlite3.dll
« on: July 22, 2024, 08:30:28 pm »
I cannot run Lazarus with SQLITE. I get the error "cannot load SQLITE client library
sqlite3.dll. Check your installation.

I did an uninstall, then downloaded the current version 3.4. I copied the sqlite3.dll in
the c:\Lazarus folder, and also the folder containing the sqlite database file
 (ending in ".db"), and windows\system32 and windows\syswow.

I have read on the internetabout using both the 32-bit and 64-bit versions of the dll, and I
tried using every comination of them in the folders mentioned. Stll get the same error message,
although sometime the error message is "cannot find the file listed. I don't know if itis
referring to the database file or the dll. I turned off my anti-virus prams and the firewall.
I then rebooted, and I sill get the "cannot load clienta library..." error.

I am runningWindows 10.

Can anyone help me on this? Thank you.

af0815

  • Hero Member
  • *****
  • Posts: 1379
Re: cannot load sqlite3.dll
« Reply #1 on: July 22, 2024, 08:58:43 pm »
If you start Lazarus from command line, did you see more information ? There are some versions of sqlit3.dll Which need some other dill's too.

Have you the problem at startup of Lazarus, or only in the designer, if you want to activate a connection.
regards
Andreas

CharlyTango

  • Jr. Member
  • **
  • Posts: 90
Re: cannot load sqlite3.dll
« Reply #2 on: July 22, 2024, 09:12:09 pm »
As af0815 mentioned

Have you the problem at startup of Lazarus, or only in the designer, if you want to activate a connection.

there are two perspectives for the access dll (sqlite3.dll).
One to establish a connection to the SQLite database in the Lazarus GUI with the help of the components (SQLDB or ZEOS) and a second to provide database functions for the created programme.

There are also other variants, but I recommend the first one:

-- first check which bitness your Lazarus has (32 or 64 bit) and select the correct sqlite3.dll.

-- copy this dll into the directory where the Lazarus.exe file is located

-- and also copy the sqlite3.dll into the directory where the generated *.EXE of your programme is located

That should usually work if the Lazarus installation is correct
Lazarus stable, Win32/64

Zvoni

  • Hero Member
  • *****
  • Posts: 2738
Re: cannot load sqlite3.dll
« Reply #3 on: July 23, 2024, 08:41:33 am »
As CharlyTango wrote:
In your Lazarus-Installation-Folder you need the SQLite-dll in the Bitness of Lazarus (!!). Same location as "lazarus.exe"
In your Project-Folder you need the SQLite-DLL in the Bitness of your Compile-Target (!!)
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

Thaddy

  • Hero Member
  • *****
  • Posts: 16157
  • Censorship about opinions does not belong here.
Re: cannot load sqlite3.dll
« Reply #4 on: July 23, 2024, 09:00:43 am »
Or put the dll's in the correct spots.
The 64 bit dll's go in windows\system32
The 32 bit dll's go in windows\sysWOW64
The above is not a mistake!! Most people do it wrong the first time.

If you do that correctly, the dll's will also be picked up correctly and you do not pollute your development and project directories.
It will solve your problems once and for all.
There should not be any shared libraries in your project directories. Noone.
You can automatically work with 32 bit and 64 bit at the same time.

(the same should be done for e.g. OpenSSL dll's)
« Last Edit: July 23, 2024, 09:08:15 am by Thaddy »
If I smell bad code it usually is bad code and that includes my own code.

CharlyTango

  • Jr. Member
  • **
  • Posts: 90
Re: cannot load sqlite3.dll
« Reply #5 on: July 23, 2024, 09:50:53 am »
@Thaddy  You are absolutely right....

... if the goal is one set of compatible dlls per database server and the idea not to pollute the project environment.

And that you are confident that the future target environment in which the programme will run is installed correctly and that there are no side effects to already installed libraries and applications.

I prefer not to pollute the operating system, especially that of the customer. That's why my programmes come with all the necessary dlls in their own directories.

Of course, installation programmes could solve some of the problems mentioned, but not all of them.

In companies with centralised rights and installation management, things may look different, but for me, this strategy causes fewer problems, but of course everyone should do as they wish
Lazarus stable, Win32/64

Thaddy

  • Hero Member
  • *****
  • Posts: 16157
  • Censorship about opinions does not belong here.
Re: cannot load sqlite3.dll
« Reply #6 on: July 23, 2024, 02:50:33 pm »
In companies with centralised rights and installation management, things may look different, but for me, this strategy causes fewer problems, but of course everyone should do as they wish
During development, feel free to do what you like, but on deployment, do not forget "the prodigal son of software engineering":
Write a proper installer... ;D
Actually it is usually the software engineer who is the sinner, not the deployer...
« Last Edit: July 23, 2024, 04:37:55 pm by Thaddy »
If I smell bad code it usually is bad code and that includes my own code.

steveinalabama

  • New Member
  • *
  • Posts: 40
Re: cannot load sqlite3.dll
« Reply #7 on: July 23, 2024, 08:43:39 pm »
I no longer get the sqlite3.dll error, but I still get "cannot find the file listed sqlite3connection1"... I assume that is the file that the connection points to. It is showing the component name. but the database file name is there.

dsiders

  • Hero Member
  • *****
  • Posts: 1282
Re: cannot load sqlite3.dll
« Reply #8 on: July 23, 2024, 09:25:28 pm »
I no longer get the sqlite3.dll error, but I still get "cannot find the file listed sqlite3connection1"... I assume that is the file that the connection points to. It is showing the component name. but the database file name is there.

Then you are probably using a relative path to the db file and it is not valid when the application is run. Use a a fully-qualified path in filename or make the path relative to the directory where the application executable lives. IOW, the difference between the current directory at design-time and run-time. Use FileExists() to check for the db file before opening.

HTH...
Preview the next Lazarus documentation release at: https://dsiders.gitlab.io/lazdocsnext

steveinalabama

  • New Member
  • *
  • Posts: 40
Re: cannot load sqlite3.dll
« Reply #9 on: July 24, 2024, 05:15:06 am »
both problems have cleared up, but now a new problem. The sqlite3connection does connect, but when I pen the query I get the error "database not assigned".
The only choices in the database oroperty on the sqlquery are "Sqlite3 connection" or "None". I tried selecting none and then typing in the path and database file name, but it would not allow it with invalid property vale when I try to move back to the form.

In the debugger I see that the connection gets connected, but the error comes when I open the query.
Any ideas?


steveinalabama

  • New Member
  • *
  • Posts: 40
Re: cannot load sqlite3.dll
« Reply #10 on: July 24, 2024, 06:07:00 am »
I finally figured out that I needed to enter the database file name in the filename property of the query. But now another problem. I get the error message that it cannot open the database file because it is being used by another process.

I rebooted and tried again, with nothing else running but get the same result.
What other process? The sqlite3connection? How can you have a query without the sqlite3connection?

What am I missing?


dseligo

  • Hero Member
  • *****
  • Posts: 1406
Re: cannot load sqlite3.dll
« Reply #11 on: July 24, 2024, 06:22:24 am »
Try this code below in separate program (ensure that you put library dll in the same directory). If it works then you can check step by step what you missed in your desktop program.
You could also make test project which shows your problem and upload it here (create zip file with menu Project/Publish Project).

Code: Pascal  [Select][+][-]
  1. program sqlite_sqldb;
  2.  
  3. uses SysUtils, sqlite3conn, sqldb;
  4.  
  5. var
  6.   SQLite3Connection: TSQLite3Connection;
  7.   Query: TSQLQuery;
  8.   Transaction: TSQLTransaction;
  9.  
  10. begin
  11.   SQLite3Connection := TSQLite3Connection.Create(nil);
  12.   Transaction := TSQLTransaction.Create(nil);
  13.   Query := TSQLQuery.Create(nil);
  14.   try
  15.     // choose database (file) name
  16.     SQLite3Connection.DatabaseName := 'mytest.db3';
  17.     SQLite3Connection.Transaction := Transaction;
  18.     try
  19.       SQLite3Connection.Connected := True;
  20.     except
  21.       on E: Exception do
  22.       begin
  23.         WriteLn('Error: ', E.Message);
  24.         Exit;
  25.       end;
  26.     end;
  27.  
  28.     Query.DataBase := SQLite3Connection;
  29.     Query.Transaction := Transaction;
  30.     Transaction.Action := caCommit;
  31.  
  32.     // check if 'mytablename' exists
  33.     Query.SQL.Text := 'select name ' +
  34.                       'from sqlite_schema ' +
  35.                       'where type = ''table'' ' +
  36.                       'and name = ''mytablename''';
  37.     Query.Open;
  38.     If Query.EOF then
  39.     begin
  40.       Query.Close;
  41.       Query.SQL.Text := 'create table mytablename ' +
  42.                         '(myid integer, somedata integer, primary key (myid))';
  43.       Query.ExecSQL;
  44.  
  45.       Query.SQL.Text := 'insert into mytablename ' +
  46.                         '(somedata) values ' +
  47.                         '(:somedata)';
  48.  
  49.       Query.ParamByName('somedata').AsInteger := 5;
  50.       Query.ExecSQL;
  51.       Query.ParamByName('somedata').AsInteger := 10;
  52.       Query.ExecSQL;
  53.       Query.ParamByName('somedata').AsInteger := 15;
  54.       Query.ExecSQL;
  55.       Query.ParamByName('somedata').AsInteger := 20;
  56.       Query.ExecSQL;
  57.       Query.ParamByName('somedata').AsInteger := 25;
  58.       Query.ExecSQL;
  59.       Query.ParamByName('somedata').AsInteger := 30;
  60.       Query.ExecSQL;
  61.     end;
  62.  
  63.     Query.Close;
  64.     Query.SQL.Text := 'select myid, somedata ' +
  65.                       'from mytablename';
  66.     Query.Open;
  67.     While not Query.EOF do
  68.     begin
  69.       WriteLn(Query.FieldByName('myid').AsInteger, ': ', Query.FieldByName('somedata').AsInteger);
  70.       Query.Next;
  71.     end;
  72.     Query.Close;
  73.   finally
  74.     Query.Free;
  75.     Transaction.Free;
  76.     SQLite3Connection.Free;
  77.   end;
  78. end.

kapibara

  • Hero Member
  • *****
  • Posts: 629
Re: cannot load sqlite3.dll
« Reply #12 on: July 24, 2024, 06:29:50 am »
It sounds like the TSQLite3connection control that you have put on a form is active in the Lazarus IDE? Simply try turning it off before you run your program from Lazarus. By default, SQLite allows only one connection to a database so if a designtime control has opened a connection then your running program can not open another.

I finally figured out that I needed to enter the database file name in the filename property of the query. But now another problem. I get the error message that it cannot open the database file because it is being used by another process.

I rebooted and tried again, with nothing else running but get the same result.
What other process? The sqlite3connection? How can you have a query without the sqlite3connection?

What am I missing?
« Last Edit: July 24, 2024, 06:42:24 am by kapibara »
Lazarus trunk / fpc 3.2.2 / Kubuntu 22.04 - 64 bit

steveinalabama

  • New Member
  • *
  • Posts: 40
Re: cannot load sqlite3.dll
« Reply #13 on: July 24, 2024, 05:23:13 pm »
The sql3connection was set to active in the IDE, but I changed it to unconnected.
Now I get the error message the data-stream format is not recognized. I have this problem on several different .db files,yet they can all be readok in dbbrowser for sqlite.

steveinalabama

  • New Member
  • *
  • Posts: 40
Re: cannot load sqlite3.dll
« Reply #14 on: July 24, 2024, 05:49:34 pm »
I get the same error message when I use the chinook sample database

 

TinyPortal © 2005-2018