我希望有人能帮我审视一下我的VB脚本。这个脚本的主要目的是使用一些参数执行存储过程。
我得到的错误是:
'Expected end of statement'
我没有做太多的VB脚本,但从我迄今为止所发现的来看 - 这个错误是由于某种语法问题引起的。我花了很多时间查看这个脚本,但没有发现任何明显的问题。我只能假设这是由于adArray
的声明引起的(在我看来它看起来不对,但我没有找到任何这样声明的示例)。这个错误只是在我开始添加更多的参数后引入的。
代码:
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
任何帮助都将不胜感激。谢谢。
编辑:
对于那些感兴趣的人 - 我的解决方案是放弃adArray并将我的数据作为逗号分隔的varchar传递。然后,我在存储过程中使用简单的拆分函数处理这些数据。
adArray
在ADO中不受支持,并且是为了未来兼容性而添加的。 - user692942