Share via


Visual Basic: RDO Data Control

rdoColumn Object, rdoColumns Collection Example

The following example opens a connection against an SQL Server database and creates an rdoResultset that returns two columns: one normal column, and one derived from an expression. Next, the example maps the rdoColumn objects returned from the result set.

  Private Sub rdoColumnButton_Click()
Dim cl As rdoColumn
Dim rs As rdoResultset
Dim sSQL As String
Dim cn As rdoConnection
Dim connect As String

connect = "uid=;pwd=;database=pubs;"

Set cn = rdoEnvironments(0).OpenConnection(workdb, _
             rdDriverNoPrompt, False, connect)

sSQL = "Select Pub_ID, Max(Price) BestPrice " _
    & " from Titles Group by Pub_ID"

Set rs = cn.OpenResultset(sSQL, rdOpenForwardOnly, _
    rdConcurReadOnly)

With rs
    For Each cl In .rdoColumns
        Print cl.Name; "-"; cl.Type; ":"; cl.Size, _
         cl.SourceTable, cl.SourceColumn
    Next cl
    Print
    Do Until .EOF
        For Each cl In .rdoColumns
            Print cl.Value,
        Next cl
        Print
        .MoveNext
    Loop
End With
End Sub