Metodo Fields

Il metodo Fields viene utilizzato per ottenere il valore della colonna del record corrente.

Sintassi

Object.Fields(ColumnInfo)

Argomenti:

  • Object: obbligatorio. Sempre il nome dell'oggetto ADODB.RecordSet.

  • ColumnInfo: obbligatorio. Può essere un nome di colonna o un indice. Se è un indice, inizierà da Zero

Note

Nell'esempio seguente viene illustrato l'uso del metodo Fields.

Esempio 1

'Create ADODB.Connection Object
Dim ConnObj   ' Create a variable.
Set ConnObj = CreateObject("ADODB.Connection")
ConnObj.Open("ConnectionString") 'Creates DB Connection by Using Connection String

Dim RecSetObj
Dim CmdTxt
CmdTxt = "SELECT * FROM EMPLOYEE_DETAILS WHERE ID = 101"
Set RecSetObj = ConnObj.Execute(CmdTxt) 'Returns RecordSet

If Not RecSetObj.Eof Then
RecSetObj.Fields(0) 'Returns value of 0th Index Column from the current Record Set
RecSetObj.Fields("SALARY") 'Returns value of SALARY Column from the current Record Set
End If

RecSetObj.Close()
ConnObj.Close() 
Set RecSetObj = Nothing
Set ConnObj = Nothing