Sub AddColumnToTable (SQL_AT As SQL, TableName As String, CToAdd As String, CFormat As String)
Dim cursor1 As Cursor
Private Row As Int
Private Query As String
Query = "PRAGMA table_info ('" & TableName & "')"
cursor1 = SQL_AT.ExecQuery(Query)
Dim Found As Boolean = False
For Row = 0 To cursor1.RowCount - 1
cursor1.Position = Row
If cursor1.getstring2(1) = CToAdd Then
Found=True
Exit
End If
Next
If Found=False Then
'File.Copy(DBDir,DBName,DBDir,DBName & DateTime.Now & "_backup") 'backup before altering table
Query = "ALTER TABLE " & TableName & " ADD COLUMN " & CToAdd & " " & CFormat
SQL_AT.ExecNonQuery(Query)
End If
Query = "PRAGMA table_info(" & TableName &")" 'Get table info -> shows column names and format
cursor1 = SQL_AT.ExecQuery(Query)
For Row = 0 To cursor1.RowCount - 1
cursor1.Position = Row
Next
End Sub