SQLite and ilogic

SQLite and ilogic

GeorgK
Advisor Advisor
911 Views
4 Replies
Message 1 of 5

SQLite and ilogic

GeorgK
Advisor
Advisor

Hello together,

 

how could I read my data from an SQLite database with iLogic? Or should I use an add-in?

 

Thank you

 

Georg

0 Likes
Accepted solutions (1)
912 Views
4 Replies
Replies (4)
Message 2 of 5

AlexFielder
Advisor
Advisor
I think you'd be better off with an addin, since you would need to copy the relevant sqlite library .dlls to the iLogicAdd folder in order to be able to reference them from within iLogic. This article looks like it might help with the addin: https://www.codeproject.com/Articles/1210189/Using-SQLite-in-Csharp-VB-Net
0 Likes
Message 3 of 5

GeorgK
Advisor
Advisor

I tried it with the add-in and it works very well. Thank you.

0 Likes
Message 4 of 5

AlexFielder
Advisor
Advisor
Accepted solution

I wondered just how difficult it would be after I replied and lo, it's actually pretty easy to get an SQLite connection from iLogic.

 

All you or any future reader needs to do is copy the relevant files to the iLogicAdd folder:

2018-07-31 12_20_25-iLogicAdd.png

 

The version of the SQLite files needs to be the x64 build, but with the files in-place as per the screenshot above, you can simply do this:

 

Option explicit On
AddReference "System.Data.SQLite.dll"
AddReference "System.Data"
Imports System.Data
Imports System.Data.SQLite
Dim sqlite_conn As SQLiteConnection
' create a new database connection:
sqlite_conn = New SQLiteConnection("Data Source=F:\path\to\your\database\file\iLogic Test.db;Version=3;")

sqlite_conn.Open()

Dim sqlite_cmd As SQLiteCommand = sqlite_conn.CreateCommand()

sqlite_cmd.CommandText = "CREATE TABLE test (id integer primary key, text varchar(100));"

sqlite_cmd.ExecuteNonQuery()

🙂

 

PS. I have attached the sqlite database I tried to attach the sqlite database I created to test this rule, but the forum said no, so if you'd like a copy please let me know! FWIW: I used the sqlitebrowser which I installed using chocolatey from here.

Message 5 of 5

GeorgK
Advisor
Advisor

That's really simple. Thank you.

0 Likes