Neste exemplo, retorna um recordset com uma pesquisa efetuada no bdados.
Dim Wcm_Pesquisa as New ADODB.Command
Dim wRs_Movto As New ADODB.Recordset
grdMovto.Rows = 1
With wcm_Pesquisa
.ActiveConnection = gConexao
.CommandType = adCmdStoredProc
.CommandText = "PesquisaMovContabPeriodo" '<= Nome da minha stored procedure
Call .Parameters.Refresh
.Parameters("@cdUnidGestora").Value = gUnidGestora 'passar os parametros
.Parameters("@dtano").Value = txtdtAno.Text
.Parameters("@cdConta").Value = txtcdConta.Text
.Parameters("@dtInicio").Value = dtpInicio.Value
.Parameters("@dtFinal").Value = dtpFinal.Value
End With
With wRs_Movto
.CursorLocation = adUseClient
Call .Open(wcm_Pesquisa, , adOpenForwardOnly, adLockOptimistic) 'executar a stored procedure
If .EOF Then
Call MsgBox("Nenhum movimento neste período!", vbInformation + vbOKOnly
Else
Do While Not .EOF 'Carregar o msFlexGrid
grdMovto.AddItem !dtLancamento & vbTab & !dsHistorico & vbtab & Format(!vldebito, "###,###,###,###,##0.00")
.MoveNext
Loop
End If
End With