ADO Stored Procedure Problem

J

Joe Delphi

Hi,

I am getting this error message: "Procedure SELECT_TPRD expects
parameter @TPRD which was not supplied"

My code is below. The error mesage and program failure happens on the
Parameters.Refresh line.

The problem is that my stored proc has a parameter @TPRD but it is an
OUTPUT parameter and is declared as such in the stored procedure. Why does
MS Access think it is an input parameter? Anyone know how to get around
this error message?

Any help appreciated.

JD
-----------------

Function SelectTprd(Optional newval As Variant) As String
Dim cmdCommand As ADODB.Command
Dim prmTPRD As ADODB.Parameter
Set cmdCommand = New ADODB.Command
cmdCommand.ActiveConnection = CurrentProject.AccessConnection
cmdCommand.CommandType = adCmdStoredProc
cmdCommand.CommandText = "[ad\jmuseck].SELECT_TPRD"
cmdCommand.Parameters.Refresh
Set prmTPRD = cmdCommand.CreateParameter("@TPRD", adChar, adParamOutput, ,
"")
cmdCommand.Execute
'Return the time period to the calling program.'
SelectTprd = cmdCommand.Parameters(1).Value
Set cmdCommand = Nothing 'Free memory End Function
 
N

Norman Yuan

You created a parameter (prmTPRD), but DID NOT add it into tne ADODB.Command
object's Parameters collection.

''After this line of code:
Set prmTPRD = cmdCommand.CreateParameter("@TPRD", adChar, adParamOutput, ,
"")

''You need to add:
cmdCommand.Parameters.Append prmTPRD

'Now you can execute the command
cmdCommand.Execute
 

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