Morning all,
Not sure if this is a bug or known behaviour :
On the latest beta DatabaseColumnType() returns 0 when using ODBC as a connection type.
I will test it using older versions but wondered if anyone else has seen this before.
Cheers
ODBC connections and DatabaseColumnType()
- captain_skank
- Enthusiast
- Posts: 639
- Joined: Fri Oct 06, 2006 3:57 pm
- Location: England
Re: ODBC connections and DatabaseColumnType()
I just tried ODBC with MySQL and SQL Server -> okay here with PB 6.10 b6 x64. 
PureBasic for Windows
- captain_skank
- Enthusiast
- Posts: 639
- Joined: Fri Oct 06, 2006 3:57 pm
- Location: England
Re: ODBC connections and DatabaseColumnType()
Code: Select all
; Execute a SQL query
If DatabaseQuery(0, PVAR_sql)
column_count.i = DatabaseColumns(0)
; get the column names and update the CSV
For loop_count = 0 To column_count
Debug DatabaseColumnName(0, loop_count)
Select DatabaseColumnType(0, loop_count) ;
Case #PB_Database_Long ; Numeric format (a Long (.l) in PureBasic)
Debug "Column " + Str(loop_count) + "#PB_Database_Long"
Case #PB_Database_Float ; Numeric float format (a Float (.f) in PureBasic)
Debug "Column " + Str(loop_count) + "#PB_Database_Float"
Case #PB_Database_Double ; Numeric double format (a Double (.d) in PureBasic)
Debug "Column " + Str(loop_count) + "#PB_Database_Double"
Case #PB_Database_Quad ; Numeric quad format (a Quad (.q) in PureBasic)
Debug "Column " + Str(loop_count) + "#PB_Database_Quad"
Case #PB_Database_Blob ; Blob format
Debug "Column " + Str(loop_count) + "#PB_Database_Blob"
Case #PB_Database_String ; String format (a String (.s) in PureBasic)
Debug "Column " + Str(loop_count) + "#PB_Database_String"
Default
Debug "Column " + Str(loop_count) + "No DB column type found"
EndSelect
Next
; get the database records and update the CSV
While NextDatabaseRow(0)
field_data.s = ""
For loop_count = 0 To column_count
Select DatabaseColumnType(0, loop_count) ;
Case #PB_Database_Long ; Numeric format (a Long (.l) in PureBasic)
field_data + GetDatabaseString(0, loop_count)
Case #PB_Database_Float ; Numeric float format (a Float (.f) in PureBasic)
field_data + GetDatabaseString(0, loop_count)
Case #PB_Database_Double ; Numeric double format (a Double (.d) in PureBasic)
field_data + GetDatabaseString(0, loop_count)
Case #PB_Database_Quad ; Numeric quad format (a Quad (.q) in PureBasic)
field_data + GetDatabaseString(0, loop_count)
Case #PB_Database_Blob ; Blob format
field_data + GetDatabaseString(0, loop_count)
Case #PB_Database_String ; String format (a String (.s) in PureBasic)
field_data + Chr(34) + GetDatabaseString(0, loop_count) + Chr(34)
EndSelect
Next
Wend
FinishDatabaseQuery(0)
Else
Debug "database error"
EndIf
But the databasecolumncount() and DatabaseColumnName() commands work fine.
cheers
Re: ODBC connections and DatabaseColumnType()
Do you mean the last column?
I think, you need to do this:
I think, you need to do this:
Code: Select all
For loop_count = 0 To column_count-1
PureBasic for Windows
- captain_skank
- Enthusiast
- Posts: 639
- Joined: Fri Oct 06, 2006 3:57 pm
- Location: England
Re: ODBC connections and DatabaseColumnType()
oops - ignore that.
But no doesn't work for any of them.
I'm doing some more experimentation at the moment and i think it's the version of the ODBC driver - if I upgrade to the newest it works fine, but in this particular use case i have to use an older 32bit version which this doesn't work with.
Cheers

But no doesn't work for any of them.
I'm doing some more experimentation at the moment and i think it's the version of the ODBC driver - if I upgrade to the newest it works fine, but in this particular use case i have to use an older 32bit version which this doesn't work with.
Cheers