How to replace an ADO.NET Datatable with SQLiteDataTable

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for SQLite
Post Reply
Uncle_John
Posts: 1
Joined: Fri 11 Sep 2009 22:31

How to replace an ADO.NET Datatable with SQLiteDataTable

Post by Uncle_John » Fri 11 Sep 2009 23:06

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

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Wed 16 Sep 2009 09:58

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

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Wed 16 Sep 2009 10:01

For more information, please refer to http://www.devart.com/dotconnect/sqlite/docs/ , the Index tab, the SQLiteDataTable Class part.

Post Reply