Page 1 of 1

How to replace an ADO.NET Datatable with SQLiteDataTable

Posted: Fri 11 Sep 2009 23:06
by Uncle_John
I have a very simple question:

What is the easiest way to migrate from a standard ADO.NET datatable that has this structure in VB.NET:
myDataTable = New System.Data.DataTable("test")
myDataTable.Columns.Add(New DataColumn("x1"))

to an in memory SQLiteDataTable that will support SQL queries like these: "SELECT min(x1) FROM test" or "SELECT DISTINCT(x1) FROM test GROUP BY x1"

Thanks.
Uncle John

Posted: Wed 16 Sep 2009 09:58
by Shalex
You don't need to care about creating a table schema manually - it will be created automatically when you use Devart.Data.SQLite.SQLiteDataTable (it is necessary to create a table schema manually with System.Data.DataTable). The corresponding usage of Devart.Data.SQLite.SQLiteDataTable can be the following:

Code: Select all

Dim myDataTable As SQLiteDataTable = New SQLiteDataTable("SELECT DISTINCT(x1) FROM test GROUP BY x1", "DataSource=mydatabase.db")
myDataTable.FetchAll = True
myDataTable.Active = True //schema is created, SqlDataTable is filled up with data

Posted: Wed 16 Sep 2009 10:01
by Shalex
For more information, please refer to http://www.devart.com/dotconnect/sqlite/docs/ , the Index tab, the SQLiteDataTable Class part.