Examples: FieldInfo method

This agent executes an SQL query and displays some of the field information about each field in the result set.

Uselsx "*LSXODBC"
Sub Initialize
  Dim con As New ODBCConnection
  Dim qry As New ODBCQuery
  Dim result As New ODBCResultSet
  Dim msg As String
  Dim fieldInfo As Variant
  Set qry.Connection = con
  Set result.Query = qry
  con.ConnectTo("ATDB")
  qry.SQL = "SELECT * FROM STUDENTS"
  result.Execute
  For i = 1 To result.NumColumns
    fieldInfo = result.FieldInfo(i)
    msg = "Field info:" & Chr(10)
    msg = msg & Chr(10) & "Table name: " & _
    fieldInfo(DB_INFO_TABLENAME)
    If fieldInfo(DB_INFO_READONLY) = DB_READONLY Then
      msg = msg & Chr(10) & "Read-only"
    Elseif fieldInfo(DB_INFO_READONLY) = _
    DB_READWRITE Then
      msg = msg & Chr(10) & "Read-write"
    Else
      msg = msg & Chr(10) & _
      "Read-only status unknown"
    End If
    msg = msg & Chr(10) & "Display size: " & _
    fieldInfo(DB_INFO_DISPLAYSIZE)
    msg = msg & Chr(10) & "Length: " & _
    fieldInfo(DB_INFO_LENGTH)
    msg = msg & Chr(10) & "Native data type: " & _
    fieldInfo(DB_INFO_NATIVE_DATATYPE)
    msg = msg & Chr(10) & "Precision: " & _
    fieldInfo(DB_INFO_PRECISION)
    Messagebox msg,, i & " " & result.FieldName(i)
  Next  
  result.Close(DB_CLOSE)
  con.Disconnect   
End Sub