Visual Basic: RDO Data Control
Requery Method Example
The following example illustrates use of the Requery method to re-execute an rdoQuery. Note that the rdoResultset is created only at form load and only re-executed on each invocation of the Requery method.
Option Explicit
Dim Cn As New rdoConnection
Dim Rs As rdoResultset
Dim Col As rdoColumn
Dim Qy As rdoQuery
Dim SQL As String
Dim TimeExpected As Single
Dim Ts As Single, Tn As Single
Private Sub SpWho_Click()
Rs.Cancel
With Rs
.Requery
While .StillExecuting
SpinGlobe
DoEvents
Wend
ShowRS
End With
End Sub
Sub ShowRS()
With Rs
Form1.Cls
For Each Col In .rdoColumns
Print Col.Name,
Next
Print
Do Until .EOF
For Each Col In .rdoColumns
Print Col,
Next
Print
.MoveNext
Loop
End With
End Sub
Sub SpinGlobe()
' Animate a globe here to show query is in progress.
Print ".";
End Sub
Private Sub Form_Load()
With Cn
.Connect = "UID=;PWD=;Database=WorkDB;" _
& "Server=sequel;Driver={SQL Server}" _
& "DSN='';"
.LoginTimeout = 5
.EstablishConnection rdDriverNoPrompt, True
Set Qy = .CreateQuery("SpWho", _
"{ call master..sp_who (?) }")
Qy.RowsetSize = 1
Set Rs = Qy.OpenResultset(rdOpenForwardOnly, _
rdConcurReadOnly, rdAsyncEnable)
Show
ShowRS
End With
End Sub