How do I associate Parameters to Command objects in ADO with VBScript?

后端 未结 3 1779
我在风中等你
我在风中等你 2020-12-19 10:28

I have been working an ADO VBScript that needs to accept parameters and incorporate those parameters in the Query string that gets passed the the database. I keep getting er

3条回答
  •  误落风尘
    2020-12-19 11:23

    After you create the parameter, you have to append it to the Command object's Parameters collection before you execute the Command:

    Set paramTotals = cmd.CreateParameter
    With paramTotals
        .Value = "tot%"
        .Name = "Param1"
    End With
    
    cmd.Parameters.Append paramTotals
    

    You may also need to specify the Type and Size properties for the Parameter. Generally, I use the arguments of the CreateParameter function to set all the necessary properties in one line:

    Set paramTotals = cmd.CreateParameter("Param1", adVarChar, adParamInput, 30, "tot%")
    cmd.Parameters.Append paramTotals
    

提交回复
热议问题