Calling SQL 2005 Stored Procedure from Classic ASP

hennessym
hennessym used Ask the Experts™
on
The following code is generating an error (Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another) on cmd.CommandType = adCmdStoredProc.

Any idea what I'm doing wrong?

Thanks in advance.


set objConn = server.CreateObject("ADODB.Connection")
objConn.Open objDBConn
 
Set cmd = Server.CreateObject("ADODB.Command")
   cmd.CommandType = adCmdStoredProc
   cmd.ActiveConnection =objConn
   cmd.CommandText = "dbo.sp_User"   
   
strEmail = Trim(Request("strEmail"))
 
cmd.Parameters.Append cmd.CreateParameter("@Email",adWChar, 1)
   
cmd("@Email") = strEmail
 
set objRS = cmd.Execute
if not objRS.EOF then
	arrUser = objRS.GetRows()
	strUserUbound = UBound(arrUser,2)
end if
 
objRS.close
set objRS = nothing

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Commented:
Did you define adCmdStoredProc?  The definition is in ADOVBS.inc (which you can download from http://www.4guysfromrolla.com/webtech/code/adovbs.txt if you don't already have it).

Commented:
This should also work:
cmd.CommandType = 4

Author

Commented:
Thanks, mkosbie.  Now I'm getting this:
Parameter object is improperly defined. Inconsistent or incomplete information was provided.

on this line:
cmd.Parameters.Append cmd.CreateParameter("@Email",adWChar, 1)

Any thoughts?

Author

Commented:
Nevermind, I just need to do this:
cmd.Parameters.Append cmd.CreateParameter("@Email",adVarWChar,adParamInput,100)

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial