Using SQLite, I’m not sure if this is normal behaviour. I’m cycling through the fields of a table and for most fields, the file type returned is ‘5’, which I believe is ‘Text’ or ‘VarChar’ field. I say most fields as when the table is created and a field is assigned as ‘REAL’ the file type returned is ‘7’. All ‘INT’ types are returned as ‘5’, again as ‘Text’ or ‘VarChar’ fields.
I’ve been reading Create Table - Sqlite and it seems that types are not strictly adhered to but, it is possible to at least specify types in the ‘Create Table’ sql.
Here is a short sample of an SQl Create Table snippet; the table is in fact created. The snippet is pulled from a larger SQL file whereby many tables are created in one hit.
CREATE TABLE tAccount_Types(
Account_Type_ID INT PRIMARY KEY ASC NOT NULL,
Account_Type_Name TEXT);
My question is, is there a way to examine a field and return the field type that was set via the initial ‘Create Table’ routine?
For completeness, here’s my code to cycle through the fields of a table “GetFields(pStrTableName as string)”
//Const MAXCOLUMN = 6
Dim rsf As RecordSet
Dim c As Integer // columns
Dim intColumns As Integer // Number of columns
'rsf = g.DB.FieldSchema(pStrTableName)
rsf = dbs.FieldSchema(pStrTableNames)
lstFields.DeleteAllRows
intColumns = rsf.FieldCount
// Add the DB columns as the heades for the ListBox
lstFields.ColumnCount = rsf.FieldCount
lstFields.Column(-1).WidthExpression = "100"
For i As Integer = 0 To rsf.FieldCount-1
lstFields.Heading(i) = rsf.IdxField(i+1).Name
Next
If Not (rsf Is Nil) Then
rsf.MoveFirst
While Not rsf.EOF
lstFields.AddRow ""
For c = 0 To intColumns -1
If c = 1 Then
'lstFields.Cell(lstFields.LastIndex,c) = GetFieldType(rsf.IdxField(c+1).Value)
lstFields.Cell(lstFields.LastIndex,c) = rsf.IdxField(c+1).Value
Else
lstFields.Cell(lstFields.LastIndex,c) = rsf.IdxField(c+1).Value
End If
Next c
rsf.MoveNext
Wend
Else
lstFields.AddRow "PROBLEM..."
End If
rsf.Close
Here’s a sample output:
https://www.dropbox.com/s/kzgy1sff4ll28an/2017-04-24_22-22-50.jpg?dl=0
https://www.dropbox.com/s/tl4njpt4rlojqdc/2017-04-24_22-15-00.jpg?dl=0