Return Values from SQL Server to MS Access

J

jtertin

Currently, I am using the following code to execute a stored
procedure. How can I support the use of RETURN values from a stored
procedure to use as a basis for user feedback? Do I just send another
parameter? I have tried adding another OUTPUT parameter and it is
correctly identified as an Input/Output parameter in the command
object (by examining it during an execution break), but I don't get a
value in it.

Thank you for any help!


Public Sub ExecuteMyProcedure(Par1 As String, Par2 As Double, Par3 As
String)
' Variables
Dim Conn1 As ADODB.Connection
Dim Cmd1 As ADODB.Command
Dim rs1 As ADODB.Recordset

' Establish connection.
Set Conn1 = New ADODB.Connection
Conn1.Open "DSN=" + stDSNName + ";UID=sa;PWD=" + stDatabasePassword
+ ";"

' Open recordset.
Set Cmd1 = New ADODB.Command
With Cmd1
.ActiveConnection = Conn1
.CommandText = "StoredProcName"
.CommandType = adCmdStoredProc
.Parameters.Refresh
.Parameters(1).Value = Par1
.Parameters(2).Value = Par2
.Parameters(3).Value = Par3
End With
Set rs1 = Cmd1.Execute()

' Delete Objects
Set rs1 = Nothing
Set Cmd1 = Nothing
Set Conn1 = Nothing
End Sub
 

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