cannot load sqlite3.dll lazarus / 16-Databases ---------------------------------------------------------------------- steveinalabama · 2024-07-22 18:30 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 · 2024-07-22 18:58 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. ---------------------------------------------------------------------- CharlyTango · 2024-07-22 19:12 As af0815 mentioned Quote from: af0815 on July 22, 2024, 08:58:43 pmHave 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 ---------------------------------------------------------------------- Zvoni · 2024-07-23 06:41 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 (!!) ---------------------------------------------------------------------- Thaddy · 2024-07-23 07:00 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) ---------------------------------------------------------------------- CharlyTango · 2024-07-23 07:50 @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 ---------------------------------------------------------------------- Thaddy · 2024-07-23 12:50 Quote from: CharlyTango on July 23, 2024, 09:50:53 amIn 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... Actually it is usually the software engineer who is the sinner, not the deployer... ---------------------------------------------------------------------- steveinalabama · 2024-07-23 18:43 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 · 2024-07-23 19:25 Quote from: steveinalabama on July 23, 2024, 08:43:39 pmI 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... ---------------------------------------------------------------------- steveinalabama · 2024-07-24 03:15 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 · 2024-07-24 04:07 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 · 2024-07-24 04:22 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][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program sqlite_sqldb; uses SysUtils, sqlite3conn, sqldb; var  SQLite3Connection: TSQLite3Connection;  Query: TSQLQuery;  Transaction: TSQLTransaction; begin  SQLite3Connection := TSQLite3Connection.Create(nil);  Transaction := TSQLTransaction.Create(nil);  Query := TSQLQuery.Create(nil);  try    // choose database (file) name    SQLite3Connection.DatabaseName := 'mytest.db3';    SQLite3Connection.Transaction := Transaction;    try      SQLite3Connection.Connected := True;    except      on E: Exception do      begin        WriteLn('Error: ', E.Message);        Exit;      end;    end;     Query.DataBase := SQLite3Connection;    Query.Transaction := Transaction;    Transaction.Action := caCommit;     // check if 'mytablename' exists    Query.SQL.Text := 'select name ' +                      'from sqlite_schema ' +                      'where type = ''table'' ' +                      'and name = ''mytablename''';    Query.Open;    If Query.EOF then    begin      Query.Close;      Query.SQL.Text := 'create table mytablename ' +                      '(myid integer, somedata integer, primary key (myid))';      Query.ExecSQL;       Query.SQL.Text := 'insert into mytablename ' +                        '(somedata) values ' +                      '(:somedata)';       Query.ParamByName('somedata').AsInteger := 5;      Query.ExecSQL;    Query.ParamByName('somedata').AsInteger := 10;      Query.ExecSQL;    Query.ParamByName('somedata').AsInteger := 15;      Query.ExecSQL;    Query.ParamByName('somedata').AsInteger := 20;      Query.ExecSQL;    Query.ParamByName('somedata').AsInteger := 25;      Query.ExecSQL;      Query.ParamByName('somedata').AsInteger := 30;      Query.ExecSQL;    end;     Query.Close;    Query.SQL.Text := 'select myid, somedata ' +                      'from mytablename';    Query.Open;    While not Query.EOF do    begin      WriteLn(Query.FieldByName('myid').AsInteger, ': ', Query.FieldByName('somedata').AsInteger);      Query.Next;    end;    Query.Close;  finally    Query.Free;    Transaction.Free;    SQLite3Connection.Free;  end;end. ---------------------------------------------------------------------- fpcoder · 2024-07-24 04:29 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. Quote from: steveinalabama on July 24, 2024, 06:07:00 amI 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? ---------------------------------------------------------------------- steveinalabama · 2024-07-24 15:23 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 · 2024-07-24 15:49 I get the same error message when I use the chinook sample database ---------------------------------------------------------------------- fpcoder · 2024-07-24 20:30 Can you upload a small testproject including a db file so we can check whats wrong? Then use Project->Publish Project in the Lazarus menu and select that the files should be zipped. Quote from: steveinalabama on July 24, 2024, 05:23:13 pmThe 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. ---------------------------------------------------------------------- Handoko · 2024-07-25 02:28 Or try my SQLite demos: https://forum.lazarus.freepascal.org/index.php/topic,65185.msg496461.h tml#msg496461 https://forum.lazarus.freepascal.org/index.php/topic,67245.msg517135.h tml#msg517135 To be able to run the code above, you need SQLite installed or have the SQLite3.dll put in the program folder. For Linux users, SQLite usually is already installed by default