Vbscript 参数对象定义不正确。提供的信息不一致或不完整
我正在开发一个经典的ASP web应用程序,因为我需要插入100条记录(记录的数量可能会改变,这取决于特定的用户选择)。为此,我使用参数化查询和预处理语句,我的代码如下:Vbscript 参数对象定义不正确。提供的信息不一致或不完整,vbscript,asp-classic,Vbscript,Asp Classic,我正在开发一个经典的ASP web应用程序,因为我需要插入100条记录(记录的数量可能会改变,这取决于特定的用户选择)。为此,我使用参数化查询和预处理语句,我的代码如下: Set objComm2=Server.CreateObject("ADODB.Command") objComm2.ActiveConnection=stConnect objComm2.Prepared=true objComm2.CommanText="insert into trader(RegistrationID
Set objComm2=Server.CreateObject("ADODB.Command")
objComm2.ActiveConnection=stConnect
objComm2.Prepared=true
objComm2.CommanText="insert into trader(RegistrationID,SalesID) values (?,?)"
objComm2.Parameters.Append objComm2.CreateParameter("@RegistrationID", adInteger, adParamInput)
objComm2.Parameters.Append objComm2.CreateParameter("@SalesID", adInteger, adParamInput)
while NOT objSel.EOF
objComm2("RegistrationID") = Session("RegistrationID")
objComm2("SalesID") = objSel("SalesInventoryID")
objComm2.Execute
objSel.MoveNext
wend
此处stConnect
包含在我的项目web配置文件中定义的连接变量,objSel
(它是一个记录集对象)包含插入操作所需的数据
现在我的问题是,当我运行此代码时,在将参数附加到命令对象时出现以下错误:
Parameter object is improperly defined. Inconsistent or incomplete information
was provided.
参数对象定义不正确。信息不一致或不完整
已提供。
我在代码中找不到任何错误。我怀疑您没有定义常量
adInteger
和adParamInput
证据:
>> Set oCmd = CreateObject("ADODB.Command")
>> oCmd.CreateParameter "@RegistrationID", adInteger, adParamInput
>>
Error Number: 3001
Error Description: Arguments are of the wrong type, are out of acceptable range, or are in conflict with one
another.
但是:
>常数adInteger=3
>>常量adParamInput=1
>>设置oCmd=CreateObject(“ADODB.Command”)
>>oCmd.CreateParameter“@RegistrationID”,adInteger,adParamInput
>>
>>我需要定义adInteger和adParamInput吗?据我所知,adInteger是dbType和adParamInput SECTION参数方向在这种情况下是一个输入谢谢你的帮助我得到了它know@kaleshanagineni我不建议手动声明这些。在您的global.asa
文件中设置一次,您就可以开始使用web应用程序的其余部分了。多年来没有使用过adovbs.inc
或adovbs.asp
,这是毫无意义的。使用元数据更干净,维护更少。@kaleshanagineni非常感谢大家的回答。
>> Const adInteger = 3
>> Const adParamInput = 1
>> Set oCmd = CreateObject("ADODB.Command")
>> oCmd.CreateParameter "@RegistrationID", adInteger, adParamInput
>>
>> <-- no news are good news.