Adding a new table in the general Database.db using script

Discussion of application development using iX Developer, including but not limited to getting started, using the functions tab, properties, objects and installation.
Post Reply
pepijn_h
Posts: 6
Joined: Mon Sep 17, 2018 2:50 am

Adding a new table in the general Database.db using script

Post by pepijn_h »

Hi all,

I'm experimenting with the report generator and I want to use SQL queries to add machine data to the report. Right now i found out that only the General (Database.db) and AuditTrail are accessible through the report generator.
I was wondering if it is possible to add a new table to the General Database so that my custom machinedata-table is printable using the report generator.

To connect to the database through script I'm using the following:

Code: Select all

using System.Data.SQLite;

/*
Other code......
*/

         using (SQLiteConnection db = new SQLiteConnection(dbPath))
			{
				db.Open();

				String tableCommand = 	"CREATE TABLE IF NOT " +
					"EXISTS MyTable (Primary_Key INTEGER PRIMARY KEY, " +
					"Text_Entry NVARCHAR(255) NULL)";

				SQLiteCommand createTable = new SQLiteCommand(tableCommand, db);

				createTable.ExecuteReader();
			}
dbPath should be in this case: @"Data Source=/Database.db;" but when i try to create the table no new table entries appear in the database viewer but also no errors. The report generator fails when trying the following query:

Code: Select all

SQL(General; select * from MyTable)
Is it possible to extend the General Database with new tables using script or is it only possible using datalogger items? (The code added above works for my custom database that is found in the project files, but here the table name also doesn't show up in the database viewer)

Kind regards and thanks in advance,

Pepijn Hogervorst

P.S. I'm using a X2pro4 terminal

wlederer
Posts: 175
Joined: Fri Jan 27, 2012 4:20 am

Re: Adding a new table in the general Database.db using scri

Post by wlederer »

Probably, yes. I will google it.
You can add a table to the Database.db with Data Logger.
And You can add an external SQLite database to USB or SD card.
The database errors are not being noticed by iX Developer. Use: try, catch (SQLiteException ).

Post Reply