ADO Tips & Tricks1) Connection Objecta)
Opening the Database
b)
Executing Commands
c)
Executing Queries
d)
Closing the Database
2) Recordset Objecta)
The Fields Collection
b)
Editing Records
3) Toolsa)
One Column Queries
b)
ComboBox Example
c)
One Row Queries
d)
Multi-Column Queries
e)
Getting Field Names
f)
ComboBox Example, 2
4) A Useful Examplea)
The SELECT Clause
b)
The WHERE Clause
c)
The Query
|
Getting
Field Names
You
can use the Recordset object and its Fields collection to get the names of
the columns returned by a query.
Public Function GetQueryFields(ByVal query As String) _As CollectionDim results As CollectionDim rs As ADODB.RecordsetDim field_num As IntegerSet results = New Collection ' Execute the query.
Set rs = m_DBConnection.Execute(query, , adCmdText) ' Save the field names in the
collection.
For field_num = 0 To rs.Fields.Count - 1results.Add rs.Fields(field_num).NameNext field_num ' Close the Recordset.
rs.Close ' Return the collection.
Set GetQueryFields = resultsEnd Function |