### Create a Database in a few steps

Example of creating a SQLite Database with one table, add some records and list those in a TableView.
Note: This example makes use of the module DBUtils.bas.
Add the SQLite Driver to the Project Attributes
#Region Project Attributes
'SQLite driver
#AdditionalJar: sqlite-jdbc-3.7.2
#End Region
Define the globals SQL object and TableView
`Sub Process_Globals
Private gSQL As SQL
Private DatabaseFile As String = "contacts.db"
Private TableView1 As TableView
End Sub`
Connect to the database file which is located in the dirapp folder
gSQL.InitializeSQLite(File.DirApp, DatabaseFile, True)
Create the table
Dim Fields As Map
Fields.Initialize
Fields.Put("Name", "TEXT")
DBUtils.CreateTable(gSQL, "Name", Fields , "Key")
Insert some Data
Dim ListOfMaps As List
ListOfMaps.Initialize
'Entry 1
Dim m As Map
m.Initialize
m.Put("Name", "Name 1")
ListOfMaps.Add(m)
'Entry 2
Dim m As Map
m.Initialize
m.Put("Name", "Name 2")
ListOfMaps.Add(m)
'Insert the Data as ListOfMaps into the Table
DBUtils.InsertMaps(gSQL, "Name", ListOfMaps)
List the Records
'List All Records
DBUtils.ExecuteTableView(gSQL, "SELECT Name FROM Name", Null, 0, TableView1)
'List 1 Record
DBUtils.ExecuteTableView(gSQL, "SELECT Name FROM Name", Null, 1, TableView1)
'List 2 Records
DBUtils.ExecuteTableView(gSQL, "SELECT Name FROM Name", Null, 2, TableView1)
Etc.

Changed: , Category: SQLite, File: T6C254M1819.htm, ID: 1819