1

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?

7
  • More specifically, the error occurs on the Set pInvoiceNumber = ... line. Commented Sep 11, 2014 at 2:14
  • Set cmd.ActiveConnection = con? Commented Sep 11, 2014 at 7:31
  • @oraclecertifiedprofessional yes. As I mentioned, it is a valid and open connection object that that point. Is that not the correct way to do it? Commented Sep 11, 2014 at 12:41
  • What I meant was, the issue might be the fact that you have not used Set. Commented Sep 11, 2014 at 12:43
  • Well perhaps you could get around explicitly defining parameters by using Refresh(): support.microsoft.com/kb/185125 ? Commented Sep 11, 2014 at 13:00

2 Answers 2

1

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
Sign up to request clarification or add additional context in comments.

1 Comment

The solution from your link is what did it. Though I also used the "Set cmd.ActiveConnection" as suggested by @oraclecertifiedprofessional.
0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.