I was reading in ch 7 of Professional ASP Data Access about using input and output parameters with the command object and an MS SQL Server stored proc. I'm having some trouble. The first code block below always passes null values for the two input parameters to the stored proc - even when a literal value is hard coded in. The second says there are to many parameters for the stored proc. I've also included the beginning of the stored proc for reference.
---code block one---
With Cmd
.ActiveConnection=Conn
.CommandText="_spTest"
.CommandType=adCmdStoredProc
Set P= .Parameters
P.Append .CreateParameter("@Email",adVarChar,adParamInput,5 0)
P.Append .CreateParameter("@fName",adVarChar,adParamInput,5 0)
P.Append .CreateParameter("@uID",adInteger,adParamOutput,4)
Cmd("@Email")="
[email protected]"
Cmd("@fName")="Ryan"
.Execute
End With
---code block two---
With Cmd
.ActiveConnection=Conn
.CommandText="_spTest"
.CommandType=adCmdStoredProc
Set pEmail= .CreateParameter("@Email",adVarChar,adParamInput,5 0)
Set pFname= .CreateParameter("@fName",adVarChar,adParamInput,5 0)
Set pUserID= .CreateParameter("@uID",adInteger,adParamOutput,4)
pEmail.Value="
[email protected]"
pFname.Value="User"
.Parameters.Append pEmail
.Parameters.Append pFname
.Parameters.Append pUserID
.Execute
End With
---stored proc---
CREATE PROCEDURE _spTest
(
@Email varchar(50),
@fName varchar(50),
@uID int OUTPUT
)
As
...
I've also tried this:
.CreateParameter("@Email",adVarChar,adParamInput,5 0,value)
where "value" is a variable or a hard coded value and it still always passes NULL to the stored proc.
Any thoughts?
Thanks a lot - Ryan