Parameter issue

  • I am trying to pass parameters to a stored procedure inside an ActiveX object and it is giving me an error on line 20 where I first try to set the Parameters Type.  The error is: Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.

    Here is the code (note the error occurs before I append the parameter, and the parameter is supposed to to VarChar(100)):

    set

    objEmailCom = CreateObject("ADODB.Command")

    objEmailCom.ActiveConnection = objEmailCon

    objEmailCom.CommandText = "mailsend"

    objEmailCom.CommandType = 4

    'To

    set objParam = CreateObject("ADODB.Parameter")

    objParam.Type = adVarChar 'This is line 20**********

    objParam.Direction = adParamInput

    objParam.Size = 100

    objParam.Value = "address"

    objEmailCom.Parameters Append objParam

    'From

    set objParam = CreateObject("ADODB.Parameter")

    objParam.Type = adVarChar

    objParam.Direction = adParamInput

    objParam.Size = 100

    objParam.Value = "address"

    objEmailCom.Parameters Append objParam

    'CC

    set objParam = CreateObject("ADODB.Parameter")

    objParam.Type = adVarChar

    objParam.Direction = adParamInput

    objParam.Size = 100

    objParam.Value = ""

    objEmailCom.Parameters Append objParam

    'Subject

    set objParam = CreateObject("ADODB.Parameter")

    objParam.Type = adVarChar

    objParam.Direction = adParamInput

    objParam.Size = 100

    objParam.Value = "Test"

    objEmailCom.Parameters Append objParam

    'Body

    set objParam = CreateObject("ADODB.Parameter")

    objParam.Type = adVarChar

    objParam.Direction = adParamInput

    objParam.Size = 100

    objParam.Value = "This is a test"

    objEmailCom.Parameters Append objParam

    objEmailCom.Execute

     

    Thanks for the help,

    Adam

  • Hey,

    You need to pass in the numerical equivalent.  Those values are defined in adovbs.inc include file which is not included in the ActiveX task.  Use the numerical equivalents.

    Brian

  • Here are some common ones.  You can copy and paste this to the top of your active X script:

    '---- DataTypeEnum Values ----

    Const adBoolean = 11

    Const adChar = 129

    Const adCurrency = 6

    Const adDBDate = 133

    Const adInteger = 3

    Const adVarChar = 200

    Const adTinyInt = 16

    Const adBinary = 128

    '---- CommandInputEnum Values ----

    Const adParamInput = 1

    Const adParamOutput = 2

  • That did it, thanks for the help!!!

  • You're welcome.  You may want to consider writing your code this way, as it's less lines than you've written.  The value would go after the field lengths, but the following stored procedure was designed to be looped through.

       Set cmdAddWO = CreateObject("ADODB.Command")

        With cmdAddWO

            .CommandType = 4 'adCmdStoredProc

            .CommandText = "dbo.RadioShack_AutoEntry;1"

            .ActiveConnection = mcnnWD

            .Parameters.Append .CreateParameter("AccountProjNo", adChar, adParamInput, 6)

            .Parameters.Append .CreateParameter("InstallType", adVarChar, adParamInput, 15)

            .Parameters.Append .CreateParameter("EUAccountNo", adVarChar, adParamInput, 20)

            .Parameters.Append .CreateParameter("EUName", adVarChar, adParamInput, 36)

            .Parameters.Append .CreateParameter("EUHomePhone", adChar, adParamInput, 10)

            .Parameters.Append .CreateParameter("EUWorkPhone", adChar, adParamInput, 10)

            .Parameters.Append .CreateParameter("EUAltPhone", adChar, adParamInput, 10)

            .Parameters.Append .CreateParameter("OrderDate", adDBDate, adParamInput)

            .Parameters.Append .CreateParameter("WorkOrder", adChar, adParamOutput, 11)

        End With

  • Actually I did write it that way at first (thank you for the suggestion though), but I changed it temporarily to the one above because I thought it would be easier to track exactly what parameter setting was causing the problem.

    Thanks,

    Adam

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply