Sub CreateTable(SQL As SQL, TableName As String, FieldsAndTypes As Map, PrimaryKey As String, Auto As Boolean) Dim sb As StringBuilder sb.Initialize sb.Append("(") For i = 0 To FieldsAndTypes.Size - 1 Dim field, ftype As String field = FieldsAndTypes.GetKeyAt(i) ftype = FieldsAndTypes.GetValueAt(i) If i > 0 Then sb.Append(", ") sb.Append("[").Append(field).Append("] ").Append(ftype) 'If field = PrimaryKey Then sb.Append(" PRIMARY KEY") 'Original line changed below If field = PrimaryKey Then sb.Append(" PRIMARY KEY") If Auto = True Then sb.Append(" AUTOINCREMENT") End If Next sb.Append(")") Dim query As String query = "CREATE TABLE IF NOT EXISTS [" & TableName & "] " & sb.ToString Log("CreateTable: " & query) SQL.ExecNonQuery(query) End Sub
Source: Billy047 @ http://www.basic4ppc.com/android/forum/threads/dbutils-android-databases-are-now-simple.8475/page-2
Last Updated on December 30, 2015