I'm trying to pass some parameters to a SQL stored procedure in my classic ASP. I've seen several posts on this and not sure what I'm doing wrong as I don't seem to see my discrepancy.
set conn = CreateObject("ADODB.Connection")
conn.open ("DSN=SERVER;UID=username;PWD=pwd;Database=MyDatabase")
set cmd = Server.CreateObject("ADODB.Command")
set cmd.ActiveConnection = conn
cmd.CommandType = adCmdStoredProc
cmd.CommandText = my_proc
cmd.Parameters.Refresh
cmd.Parameters(1) = "MyParam"
set rs = cmd.execute
I'm getting the error
Arguments are of the wrong type, are out of acceptable range, or are in conflict
with one another.
on the line cmd.CommandType = adCmdStoredProc
. I also tried to do it the following way with the same error
set conn = CreateObject("ADODB.Connection")
conn.open ("DSN=SERVER;UID=username;PWD=pwd;Database=MyDatabase")
set cmd = Server.CreateObject("ADODB.Command")
set cmd.ActiveConnection = conn
cmd.CommandType = adCmdStoredProc
cmd.CommandText = my_proc
cmd.Parameters.Refresh
cmd.Parameters.Append cmd.CreateParameter("@MyParam, adVarWChar, adParamInput, 50, "test")
set rs = cmd.execute
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…