ADO Tips & Tricks

1)     Connection Object

a)      Opening the Database

b)      Executing Commands

c)       Executing Queries

d)      Closing the Database

2)     Recordset Object

a)      The Fields Collection

b)      Editing Records

3)     Tools

a)      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 Example

a)      The SELECT Clause

b)      The WHERE Clause

c)       The Query

 

Download Example Programs

 

 

 

 

The SELECT Clause

' Build a select clause for the selected fields.

Private Function SelectClause() As String

Dim i As Integer

Dim select_clause As String

 

    For i = 1 To FieldNames.Count

        If SelectedFields(i) Then

            select_clause = select_clause & _

                FieldNames(i) & ", "

        End If

    Next i

 

    ' Remove the trailing comma if necessary.

    If Len(select_clause) > 0 Then

        select_clause = "SELECT " & _

            Left$(select_clause, Len(select_clause) - 2)

    Else

        select_clause = "SELECT *"

    End If

 

    SelectClause = select_clause

End Function