I'm trying to dynamically build the parameters of a stored procedure. It can be one of several procedures with different arguments, so I don't know the names in advance. How would I add the parameters (I have an array of them) without knowing the parameter names? I tried the following:
set cmd = Server.CreateObject("ADODB.Command")
cmd.ActiveConnection = cn
cmd.commandText = proc
cmd.commandType = 4
dim param
For i = 0 To UBound(params)
set param = cmd.CreateParameter
param.Value = params(i)
cmd.Parameters.Append param
Next
set rs = cmd.Execute
I get the following error at the line where I try to append:
ADODB.Parameters error '800a0e7c'
Parameter object is improperly defined. Inconsistent or incomplete information was provided.
Edit:
I tried:
cmd.Parameters.Refresh
For i = 0 To UBound(params)
params(i) = Replace(params(i), "'", "")
cmd.Parameters(i).Value = CStr(params(i))
Next
I get:
ADODB.Parameter error '800a0d5d' Application uses a value of the wrong type for the current operation Further edit: I don't know the parameter types either in advance but the arguments are assumed to be correct.
<message edited by spry on Wednesday, October 07, 2009 10:08 PM>