Forum > Database
SQLite3Connection testing
MoonWolf_001:
Hi, I am MoonWolf from Japan. New to here. And Lazarus user in Japanese.
I have a DB question. I am looking for 100% sure DB Connection logic.
Test Case:
DBMS : SQLIte3 64bit for Win
A Table : created by SQLite3
Lazarus : v3.6 in Japanese
OS : Windows 11 Pro v24H2 in Japanese
Component : Form1 , SQLite3Connection
[1] Place SQLite3Connection on Form1
[2] Enter DB name to DataBaseName( ex. TEST01 )
[3] Check the connection by OI Connected -- Cannot be activated
[4] Restart Lazarus
[5] Check the connection by OI Connected -- Connected
// OI = Object Inspector
Many of case, by doing this, the connection is established.
But this is not 100% sure.
If it's not done, these are my alternatives,
1. check SQLite3.DLL or overwrite the DLL for new one.
2. check Third Party Security Program
and do on..
Do you have any other idea so that make SQLite3Connection stable?
It would be really appreciate if I could have some advice.
rvk:
--- Quote from: MoonWolf_001 on November 11, 2024, 10:57:13 am ---1. check SQLite3.DLL or overwrite the DLL for new one.
2. check Third Party Security Program
and do on..
Do you have any other idea so that make SQLite3Connection stable?
It would be really appreciate if I could have some advice.
--- End quote ---
Where did you copy the SQLite3.dll?
You need it at two locations.
When using the IDE you need the SQLite3.dll inside the directory where lazarus.exe is.
And for running your program outside the IDE, you need it in the directory of your .exe.
Zvoni:
--- Quote from: rvk on November 11, 2024, 11:05:50 am ---
--- Quote from: MoonWolf_001 on November 11, 2024, 10:57:13 am ---1. check SQLite3.DLL or overwrite the DLL for new one.
2. check Third Party Security Program
and do on..
Do you have any other idea so that make SQLite3Connection stable?
It would be really appreciate if I could have some advice.
--- End quote ---
Where did you copy the SQLite3.dll?
You need it at two locations.
When using the IDE you need the SQLite3.dll inside the directory where lazarus.exe is.
And for running your program outside the IDE, you need it in the directory of your .exe.
--- End quote ---
And remember the "bitness":
If your Lazarus-IDE is 64-Bit, you need the 64-Bit SQlite3.dll besides the lazarus.exe, if IDE is 32Bit.....
If Target-Bitness is 64Bit, you need 64Bit Sqlite3.dll besides the project.exe, if 32Bit....
All said: You're using the GUI-components, so i'm out of here....
backprop:
--- Quote from: MoonWolf_001 on November 11, 2024, 10:57:13 am ---1. check SQLite3.DLL or overwrite the DLL for new one.
2. check Third Party Security Program
and do on..
Do you have any other idea so that make SQLite3Connection stable?
--- End quote ---
In my experience, always is better to provide SQLite library which is fully tested with executable. Any new "stable" version may actually be incompatible, broken, slower etc.
--- 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";}};} ---uses sqlite3dyn;...procedure TfrmMain.FormCreate(Sender: TObject);begin sqlite3dyn.SQLiteDefaultLibrary := 'libsqlite3.so.0.8.6'; /// Similar with windows library, with full path optionally ...
backprop:
DB creation example:
--- 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";}};} ---procedure CreateDB(Filename: string);var Connect: TSQLite3Connection; Trans: TSQLTransaction; st: TStringList;begin Connect := TSQLite3Connection.Create(nil); Trans := TSQLTransaction.Create(Connect); st := TStringList.Create; try Connect.Transaction := Trans; Connect.DatabaseName := Filename; Trans.StartTransaction; // Create database st.Clear; st.Add('CREATE TABLE IF NOT EXISTS...'); // whatever Connect.ExecuteDirect(st.Text); // additional statements, commit at end Trans.Commit; finally st.Free; Trans.Free; Connect.Free; end; end;
Similar with query, just use TSQLQuery. I can provide examples if you want.
Navigation
[0] Message Index
[#] Next page