VBScript中的CreateParameter

时间:2017-01-18 11:25:44

标签: vbscript ado

执行以下代码时出错。以下是代码

oConn.Open strConnectionString, strUserName, strPassword
Set objCommand = CreateObject("ADODB.Command")
'Create and populate the paramaters collection
With objCommand
  .ActiveConnection = oConn
  .CommandText = "my sp"
  .CommandType = 4
  .Parameters.Append .CreateParameter("my parameter", adVarChar, adParamInput, 20, "my value")
  Set objRecordset = .Execute
End With

添加参数时出错。

1 个答案:

答案 0 :(得分:-1)

在普通的VBScript中,没有定义ad *常量。证据:

>> Set c = CreateObject("ADODB.Command")
>> c.CreateParameter "my parameter", adVarChar, adParamInput, 20, "my value"
>>
Error Number:       3001
Error Description:  Die Argumente sind vom falschen Typ, liegen außerhalb des Gültigkeitsbereiches oder sind miteinander unvereinbar.
>> adVarChar = 200
>> adParamInput = 1
>> c.CreateParameter "my parameter", adVarChar, adParamInput, 20, "my value"
>>
>> (No news are good news)

所以定义它们。

see also