Forum > Databases
cannot load sqlite3.dll
steveinalabama:
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:
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 [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---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.
kapibara:
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 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?
--- End quote ---
steveinalabama:
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:
I get the same error message when I use the chinook sample database
Navigation
[0] Message Index
[#] Next page
[*] Previous page