本文介绍了VBScript/ADODB语法adArray是否有问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望有人可以让我对vb脚本有新的了解.该脚本的主要目的是使用一些参数来执行存储过程.

I'm hoping somebody could provide me with some fresh eyes on my vb script. The main purpose of this script is to execute a stored procedure using some parameters.

我得到的错误是

我没有做太多的VB脚本编写,但是到目前为止,我发现的错误-归结于某种语法问题.我已经看了这个脚本好几个小时了,看不到任何明显的东西.我只能认为这取决于adArray的声明(在我看来,它看起来不正确,但我无法找到被声明的任何示例).仅在我开始添加更多参数时才引入此错误.

I haven't done much VB scripting but from what I have found so far - this error has been down to some kind of syntax issue. I've looked over this script for many hours and can't see anything obvious. I can only assume it's down to the declaration of adArray (which doesn't look right in my eyes but I haven't been able to find ANY examples of this being declared). This error has only been introduced when I started adding more parameters.

代码:

Const adVarChar = 200
Const adParamInput = 1
Const adArray = 0x2000

Dim cmd
Dim sp
Dim intCode
Dim addIn
Dim groupCode
Dim screens
Dim arrScreens
arrScreens=split(LF06,",")

Set cmd=CreateObject("ADODB.Command")
sp="vfile_dev.dbo.vfp_groupReorder"

Set intCode=CreateObject("ADODB.Parameter")
intCode.Direction=adParamInput
intCode.name="@p_intCode"
intCode.Size=100
intCode.Type=adVarChar
intCode.Value=LF03

Set addIn=CreateObject("ADODB.Parameter")
addIn.Direction=adParamInput
addIn.name="@p_addIn"
addIn.Size=100
addIn.Type=adVarChar
addIn.Value=LF04

Set groupCode=CreateObject("ADODB.Parameter")
groupCode.Direction=adParamInput
groupCode.name="@p_groupCode"
groupCode.Size=100
groupCode.Type=adVarChar
groupCode.Value=LF05

Set screens=CreateObject("ADODB.Parameter")
screens.Direction=adParamInput
screens.name="@p_screens"
screens.Size=100
screens.Type=adArray
screens.Value=arrScreens

With cmd
   .ActiveCOnnection = "Provider='sqloledb';Data source='xxx';Integrated Security='SSPI';"
   .CommandType = 4
   .CommandText = sp
   .Parameters.Append intCode
   .Parameters.Append addIn
   .Parameters.Append groupCode
   .Parameters.Append screens
   .Execute
End With

Set cmd = Nothing
Set sp = Nothing
Set intCode = Nothing
Set addIn = Nothing
Set groupCode = Nothing

任何帮助将不胜感激.谢谢.

Any help would be much appreciated. Thanks.

对于那些感兴趣的人-我的解决方案是抛弃adArray并将我的数据作为逗号分隔的varchar传递.然后,我使用简单的split函数在存储过程中处理这些数据.

For those interested - my solution was to ditch adArray and pass my data through as a comma delimited varchar. I then handle this data in my stored procedure with a simple split function.

推荐答案

我很确定adArray尽管在ADO常量中定义,但是ADO不支持adArray,并且为了将来的兼容性而添加了adArray.

I'm fairly sure adArray although defined in the ADO constants is not supported by ADO and was added for future compatibility.

此定义建议仅将其与另一个ADO DataTypeEnum常量值一起使用,以表示该数据类型的Array.

This definition suggests it should only be used with another ADO DataTypeEnum constant value to denote an Array of that Data Type.

尽管有人建议将OR值与另一个DataTypeEnum常量一起使用,但我发现这是在12年前.

Although there is some suggestion that ORing the value with another DataTypeEnum constant should work, I found this from the 12 years ago.

大卫,

adArray,它是为了将来的兼容性而创建的. 您需要实现什么?也许我们可以为您提供其他解决方案
-
Val Mazur
微软MVP
检查病毒警报,保持最新状态
http://www.microsoft.com/security/incident/blast.asp

adArray is not supported in ADO and was created for future compatibility. What do you need to achieve? Maybe we could help with another solution
--
Val Mazur
Microsoft MVP
Check Virus Alert, stay updated
http://www.microsoft.com/security/incident/blast.asp


有用的链接

09-18 10:04