ADODB_Recordset.Fields().Value

<< Click to Display Table of Contents >>

Navigation:  ThinBASIC Modules > ADODB > ADODB Module Classes > ADODB_Recordset > ADODB_Recordset Collections > ADODB_Recordset.Fields >

ADODB_Recordset.Fields().Value

 

Description

 
Returns the value of a Field object.

 

Syntax

 

s = <ADODB_Recordset>.Fields(Name | lIndex).Value

 

Returns

 

String: automatically converted from supported DataTypeEnum

 

Parameters

 

Single Field inside a Fields Collection can be reached indicating Field Number (from 1 to <ADODB_Recordset>.Fields.Count) or indicating Field Name (the name of the column in the RecordSet)

 

Name

Type

Optional

Meaning

Name

String


Field Name (the name of the column in the RecordSet)

lIndex

Numeric


Field Number (from 1 to <ADODB_Recordset>.Fields.Count)

 

 

Remarks

 

This property automatically convert original field data type into a string

 

Restrictions

 

See also

 

Examples

 

Uses "Console"

Uses "ADODB"

 

'---Declare a new pConnection variable and instantiate it in one line

Dim pConn As New ADODB_CONNECTION

 

printl "-----------------------------------------"

printl " Connection info"

printl "-----------------------------------------"

'---Set the provider and open a DB

pConn.Provider = "Microsoft.Jet.OLEDB.4.0"

pConn.Open(APP_SourcePath & "Biblio.mdb")

 

'---Print some info

PrintL pConn.Provider

Printl pConn.ConnectionString

 

'---If connection is open then Executes a command and print some data

If pConn.State = %ADSTATEOPEN Then

 

  Dim pRS     As New ADODB_RECORDSET

  Dim sSql    As String

  dim nRec    as Long

  dim nField  as Long

 

  PrintL

  printl "-----------------------------------------"

  printl " SQL Query info"

  printl "-----------------------------------------"

  sSql = "Select * from Authors order by Au_ID"' Where Au_ID = 1"

  PrintL "Query is:", sSql

 

  '---Connection Execute 

  pRS = pConn.Execute(sSql)

 

  printl

  printl "-----------------------------------------"

  printl " Recordset state:", pRS.State

  printl "-----------------------------------------"  

 

  if pRS.State = %adStateOpen Then

 

    printl

    printl "-----------------------------------------"

    printl " List Recordset fields info"

    printl "-----------------------------------------"

    printl "Number of fields:", pRS.Fields.Count

 

    for nField = 1 to pRS.Fields.Count

      printl "Field Name", nField & ":", pRS.Fields(nField).Name

      printl $TAB"Type:", pRS.Fields(nField).Type & " (" & , pRS.Fields(nField).Type$ & ")"

      printl $TAB"DefinedSize:", pRS.Fields(nField).Definedsize

      printl $tab"ActualSize:", pRS.Fields(nField).Actualsize

    Next

    

    printl

    printl "-----------------------------------------"

    printl " List some data"

    printl "-----------------------------------------"

    

    nRec = 0

    While not pRS.EOF and nRec <= 9

      'printl pRS.Collect("Au_ID"), pRS.Collect("Author"), , pRS.Collect("Year Born")

      printl pRS.Fields("Au_ID").Value, pRS.Fields("Author").Value, , pRS.Fields("Year Born").Value

      incr nRec

      pRS.MoveNext

    Wend

  

    pRS.Close

  end If

  

  pConn.Close

 

end If

 

WaitKey