Sub bFieldExists(sTableName As String, sFieldName As String) As Boolean
' SQLite command pragma table_info returns values in the fields: cid, name, type, notnull, dflt_value, pk
' These can be searched through to check if a field exists, or get the field type etc.
' SQL1 is defined global as SQL. To be init using If SQL1.IsInitialized = False Then SQL1.Initialize(...
' Usage: If bFieldExists(sDBTable, sDBField) = True Then ...
Dim curTable As Cursor
Dim sSQLCommand As String
Dim i As Int
Dim Result As Boolean
Result = False
sSQLCommand = "PRAGMA table_info(" & sTableName & ")"
Try
curTable = SQL1.ExecQuery(sSQLCommand)
For i = 0 To curTable.RowCount - 1
curTable.Position = i
If curTable.GetString("name") = sFieldName Then Result = True
Next
curTable.Close
Catch
Msgbox("SQL Error: " & LastException.Message, "")
End Try
Return Result
End Sub