vbscript - excuting stored procedure error

Posted on 2011-05-02
Last Modified: 2012-05-11
I have a vbscript that I would like to call out a stored procedure and execute.  There's one parameter that will be use.  However, I kept getting the following error.

Arguments are of the wrong type, are out of acceptable range, or are in conflit with one another. At line 8 position 0.

Below is my script.

Dim cmd
Dim sp


Set cmd = CreateObject("ADODB.Command")
Set par1 = CreateObject("ADODB.Parameter")

par1.Direction=adParamInput = "@PO"
par1.size = 30
par1.Type = adVarchar
par1.Value = ORDER_ID

With cmd
.ActiveConnection = "Provider=SQLOLEDB;Server=DBSVR1;Database=TESTDB;UID=USER1;pwd=Password1"
	.CommandType = 4
	.CommedText = sp
End With

Set cmd = Nothing
Set par1 = Nothing

Open in new window

Question by:holemania
    LVL 30

    Accepted Solution

    That is because you're using constants that VBScript doesn't recognize.

    Add this to the top of your code:

    Const adParamInput = 1
    Const adVarChar = 200

    Now try it.

    LVL 59

    Expert Comment

    by:Chris Bottomley
    Line 8 try modifying:

    Set par1 = CreateObject("ADODB.Parameter")
    Set par1 = cmd.parameter


    Author Comment

    Thanks there were a number of issues, but got it working now.

    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    Join & Write a Comment

    I met Paul Devereux (@pdevereux) today when I responded to his tweet asking “Anybody know how to automate adding files from disk to a folder in #outlook  ?”.  I replied back and told Paul that using automation, in this case scripting, to add files t…
    When it comes to writing scripts for a Client/Server computing environment it is essential to consider some way of enabling the authentication functionality within a script. This sort of consideration mainly comes into the picture when we are dealin…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now