Purpose of this article
This article aims to show you how to download, install and connect SQLite 3 with ADISRA SmartView.
Downloading and Installing SQLite 3
SQLite is a library made with C language for the user to implement a database in a simple and fast way. It is usually used for small applications.
- Go to the website https://sqlitestudio.pl/ and download the latest version of SQLite Studio.
- Download the latest version of SQLite.
Note: After downloading SQLite Studio, it is not necessary to install it, as the executable file is already available in the folder.
- Then download the ODBC driver compatible with your processor (x64 or x86) available from the links below.
Link Driver(x86): https://adisra.com/wp-content/uploads/2020/03/sqliteodbc_w32_Driver.zip
Link Driver(x64): https://adisra.com/wp-content/uploads/2020/03/sqliteodbc_w64_Driver.zip
- Install the ODBC driver.
- Extract the SQLite Studio files and run the SQLiteStudio.exe file.
- Now, let’s create a “Database” as an example. So, click on the “Database” menu, then click on the “Add a database” option.
- In the “Database type” field, keep SQLite3 and in the “File” field, put the database name as “DB_Adisra”. Then click OK.
- In the navigation tree, expand the database and then right-click on the item “Tables” and then click on “Create a Table”.
- In the “Table name:” field, enter the name “Person” for the new table.
- Now let’s create a column inside the “Person” table. To do this, click on the “Add Columns” button as shown in the image below.
- In the “Column name” field, enter Name, in the “Data type:” field, enter VARCHAR and in the “Size:” field, enter the value 50 as shown in the image below and then click OK.
- Below the first column of the “Person” table created successfully.
- Validate the changes click on the “Commit Structure Changes” button. After clicking this button, a window will open. Click OK.
- Now, let’s insert data into our “Name” column. To do so, click on the “Data” tab and then click on the “Insert Row” button.
- Insert three lines with some names as shown in the image below and click on the “Commit” button to validate.
Adding DSN in ODBC Data Source
Now, we will add a DSN in the Windows ODBC Data Source.
- In the Windows start menu, search for “ODBC Data Source”. Click on ODBC Data Source x64 or x86 bits. It is also possible to access the “ODBC Data Source” configuration via the path (Control Panel -> Administrative Tools -> ODBC Data Sources).
- In the ODBC Data Source settings window, click on the “Add…” button to add a new source.
- Then select the Driver “SQLite3 ODBC Driver and then click Finish button.
- In the “Data Source Name:” field, enter the name of the new source. Put “DB_ADISRA”. In the “Databse Name:” field, click on the “Browse…” button and search for the path of the database created in SQLite Studio”.
- Probably the “DB_Adisra.db” file is in the SQLite Studio folder as shown in the image below. Select the file and click the “Open” button.
- Then click on the OK button.
- The new ODBC source was created successfully. Now click OK.
Configuring ADISRA SmartView
- Create a new application. In the top menu, click on the “Settings” tab and click on the “Database Connections” option.
- Click the “+” button to add a new connectivity.
- Select the “Microsoft ODBC Data Source” option and click OK.
- Select the option “Use user or system data source name:” and then in the list below click on the database “DB_ADISRA”, in which it was created previously.
- Test the communication by clicking the “Test Connection” button. Then click the OK button in the test window and then click OK to close the configuration window.
- Keep the database name as “ODBC001” and click OK.
Querying DB_ADISRA database information
- Create a new Graphic, insert a “Datagrid” object.
- In the property list of the datagrid object, in the “Datagrid Config” property, select the option “Table”, “ODBC001” and “Person”.
- In the list below, enter exactly the name of the column in which we will make the query, that is, the column “Name” created in SQL Studio. Also enter the width of the “Name” column of the datagrid object. Then click on the “Add” button. If you want, you can remove the blank column.
- Below the expected result.
- Now, save the application and set “Graphic1” as the initial Graphic of the Runtime and then start the RunTime. Below the expected result.