调用SQL存储过程时出错 [英] Error Calling SQL Stored Procedure
本文介绍了调用SQL存储过程时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在vba中执行sql server stored proc。这是sp:
I''m trying to execute a sql server stored proc in vba. This is the sp:
展开 | 选择 | Wrap | / span> 行号
推荐答案
@ bullfrog83
尝试:
@bullfrog83
Try:
展开 | 选择 | Wrap | 行号
@Christopher Nigro
那是行不通的,因为它传递了这样的值:''226,227,228''它应该是''226'','227'' '' 228 ''。即使我将变量变为字符串,所以我可以将其逗号分隔,但值都是整数。
现在,为了纠正我添加了开始和结束的撇号,当我'我在代码的这一部分将值汇总在一起:
strTakenClassIds = strTakenClassIds& "" &安培; lngTakenClassId& ","
然后我收到原始错误消息。
@Christopher Nigro
That doesn''t work because then it passes the values like so: ''226,227,228'' when it should be ''226'',''227'',''228''. Even though I dimmed my variable as a string so I can make it comma-separated, the values are all integers.
Now, to correct I added the opening and closing apostrophes when I''m stringing the values together in this part of my code:
strTakenClassIds = strTakenClassIds & "''" & lngTakenClassId & "'',"
But then I get the original error message back.
如果需要:
''226 '',''227'',''228''
然后你需要让它看起来像:
''''''226 '''''''''227'''''''''228''''
这些都是单引号......
If it needs to be:
''226'',''227'',''228''
Then you need to make it look like:
''''''226'''',''''227'''',''''228''''''
Those are all single quotes...
这篇关于调用SQL存储过程时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文