Sub CreateTable(SQL As SQL, TableName As String, FieldsAndTypes As Map, PrimaryKey As String)
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")
Next
sb.Append(")")
Dim query As String
query = "CREATE TABLE IF NOT EXISTS [" & TableName & "] " & sb.ToString
Log("CreateTable: " & query)
SQL.ExecNonQuery(query)
End Sub