Dave Johnson
Dave Johnson

Reputation: 825

ADO Parameter Error in VBScript

I have tried many, many things, but keep getting error 3001 (Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another) when trying to add parameters to a command object.

Set cmd = CreateObject("ADODB.Command")
cmd.ActiveConnection = con
cmd.CommandText = "ProcName"                
cmd.CommandType = 4 'adCmdStoredProc

MsgBox("0")
'cmd.Parameters.Append(cmd.CreateParameter("@InvoiceNumber", adVarChar, adParamInput, 100, sInvoice))
Set pInvoiceNumber = cmd.CreateParameter("@InvoiceNumber", adVarChar, adParamInput, 100, sInvoice)
cmd.Parameters.Append(pInvoiceNumber)

The connection object is valid and open at the time that this code runs. The @InvoiceNumber parameter of the stored procedure is a varchar(100). What am I missing here?

Upvotes: 1

Views: 2494

Answers (2)

LoZo
LoZo

Reputation: 148

I solved the problem with include library ADOLib.inc on top of the asp.page

Upvotes: 0

lurker
lurker

Reputation: 159

I'm not able to replicate the issue, but I'm working in Classic ASP. I found this post which sounds like it may be relevant though.

VBA: Run-time error 3001 Arguments Are Of The Wrong Type... when setting ADODB.Command object members

It seems the adVarChar and adParamInput constants may be the problem due to late binding. The resolution was to add the constants to the Sub header.

If that's not feasible, try using Oracle Certified Professional's suggestion of Refresh

Set cmd = CreateObject("ADODB.Command")
cmd.ActiveConnection = con
cmd.CommandText = "ProcName"                
cmd.CommandType = 4 'adCmdStoredProc
cmd.Parameters.Refresh
cmd.Parameters(0).Value  = sInvoice

Upvotes: 1

Related Questions