Basic Question

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
 
D

Douglas J. Steele

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.
 
B

BillT

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
 
R

Ron Hinds

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top