Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 307
  • Last Modified:

Store Procedure Error

Why am I getting this error:
"Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another."

At this line:
cmd.Parameters.Append cmd.CreateParameter("PID", adInteger, adParamInput)
   


SP+++++++++++++++++++++++++++++++++
CREATE procedure sp_GetProduct
@PID int
AS
Begin
   select * from products where productid = @PID

end

GO


ASP++++++++++++++++++++++++++++++++++++++++++++
Set conn = Server.CreateObject("ADODB.Connection")
   conn.Open "XXX", "XXX", "XXXXXXXX"
   Set cmd = Server.CreateObject("ADODB.Command")
   Set cmd.ActiveConnection =conn
   Const adCmdStoredProc = 4
   cmd.Parameters.Append cmd.CreateParameter("PID", adInteger, adParamInput)  
   cmd("PID") = 100
   cmd.Execute
0
webdork
Asked:
webdork
1 Solution
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
Set conn = Server.CreateObject("ADODB.Connection")

   conn.Open "XXX", "XXX", "XXXXXXXX"
   Set cmd = Server.CreateObject("ADODB.Command")
   Set cmd.ActiveConnection =conn
   Const adCmdStoredProc = 4
set p = cmd.CreateParameter("PID", adInteger, adParamInput)  
   cmd.Parameters.Append   p

p.value = 100
   cmd.Execute
0
 
webdorkAuthor Commented:
Revised ASP code still error  

ASP++++++++++++++++++++++++++++++++++++++++++++
Set conn = Server.CreateObject("ADODB.Connection")
   conn.Open "XXX", "XXX", "XXXXXXXX"
   Set cmd = Server.CreateObject("ADODB.Command")
   Set cmd.ActiveConnection =conn
   Const adCmdStoredProc = 4
   cmd.CommandText = " sp_GetProduct "
   cmd.CommandType = adCmdStoredProc
   cmd.Parameters.Append cmd.CreateParameter("PID", adInteger, adParamInput)  
   cmd("PID") = 100
   cmd.Execute
0
 
homemadeCommented:
Are you including adovbs.inc or defining adInteger and adParamInput elsewhere in your code?
If not that could be the problem.

If your not using adovbs.inc here are the constants defined:

'---- ParameterDirectionEnum Values ----
   Const adParamInput = &H0001

   '---- DataTypeEnum Values ----
   Const adInteger = 3
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now