LOTUS CONNECTORS


Examples: FieldNativeDataType method
This agent executes an SQL query and displays the column number, name, and data type of each field in the result set. The text for the data type is obtained by examining all possible return values to FieldNativeDataType.

Uselsx "*LSXODBC"

Sub Initialize
 Dim con As New ODBCConnection
 Dim qry As New ODBCQuery
 Dim result As New ODBCResultSet
 Dim msg As String
 Set qry.Connection = con
 Set result.Query = qry
 con.ConnectTo("ATDB")
 qry.SQL = "SELECT * FROM STUDENTS"
 result.Execute
 msg = "Fields in STUDENTS table:" & Chr(10)
 For i = 1 To result.NumColumns
   msg = msg & Chr(10) & i & " " & result.FieldName(i) _
   & " " & GetDataType(result.FieldNativeDataType(i))
 Next
 Messagebox msg,, "Field names"
 result.Close(DB_CLOSE)
 con.Disconnect
End Sub

Function GetDataType(typeConst As Integer) As String
 Select Case typeConst
 Case SQL_CHAR : GetDataType = "CHAR"
 Case SQL_NUMERIC : GetDataType = "NUMERIC"
 Case SQL_DECIMAL : GetDataType = "DECIMAL"
 Case SQL_INTEGER : GetDataType = "INTEGER"
 Case SQL_SMALLINT : GetDataType = "SMALLINT"
 Case SQL_FLOAT : GetDataType = "FLOAT"
 Case SQL_REAL : GetDataType = "REAL"
 Case SQL_DOUBLE : GetDataType = "DOUBLE"
 Case SQL_DATE : GetDataType = "DATE"
 Case SQL_TIME : GetDataType = "TIME"
 Case SQL_TIMESTAMP : GetDataType = "TIMESTAMP"
 Case SQL_VARCHAR : GetDataType = "VARCHAR"
 Case SQL_BINARY : GetDataType = "BINARY"
 Case SQL_VARBINARY : GetDataType = "VARBINARY"
 Case SQL_LONGVARCHAR : GetDataType = "LONGVARCHAR"
 Case SQL_LONGVARBINARY : GetDataType = "LONGVARBINARY"
 Case SQL_BIGINT : GetDataType = "BIGINT"
 Case SQL_TINYINT : GetDataType = "TINYINT"
 Case SQL_BIT : GetDataType = "BIT"
 End Select
End Function

See Also