Basic Question

  • Thread starter Thread starter BillT
  • Start date Start date
B

BillT

I am learning to convert my MDB applications to SQL
Server 2000. I have a very basic question. I have a
stored proc in SQL that returns a set of records. If I
run the stored proc from VBA code, how do I display the
records? If I run the stored proc from a pass-thru
query, the records display fine, but I need to be able to
run the stored proc from code.

Thanks in advance.

BillT
 
What do you mean by you need to be able to run the stored proc from code?

If what you're trying to do is change what values are passed to the stored
procedure, you can always change the SQL property of the pass-through query.
 
Doug,

Thanks for the reply. How would I change the content of
a pass-thru query using ADO? I want to supply a
parameter to a stored query from a control on a form, run
the query and display the results to the user and I want
to avoid using DAO. Thanks in advance for your help.

BillT
 
BillT said:
Doug,

Thanks for the reply. How would I change the content of
a pass-thru query using ADO? I want to supply a
parameter to a stored query from a control on a form, run
the query and display the results to the user and I want
to avoid using DAO. Thanks in advance for your help.

BillT

Dim oConn As New ADODB.Connection
Dim oComm As New ADODB.Command
Dim oParam As ADODB.Parameter
Dim oRS As ADODB.Recordset

oConn.Open <your connect string>
oComm.ActiveConnection = oConn
oComm.CommandType = adCmdStoredProc

Set oParam = oComm.CreateParameter
oParam.Value = <YourControl>.Text
oComm.Parameters.Append oParam

(repeat above for each param)

Set oRS = oComm.Execute <YourStoredProc>

(use recordset)
(cleanup)
 
Back
Top