use*_*006 1 vbscript asp-classic
我需要帮助解决一个非常烦人的问题,我从今天早上 8 点开始就一直在研究这个问题。在调试经典的 asp 错误方面,我绝不是专业人士。但是,我知道的足以弄清楚发生了什么,但不完全确定如何处理/根除此问题:
问题:sql 查询不会返回任何会导致我的数组为空的内容,这给了我标题中指定的错误。
代码:
233 while not rs.eof
234 varCampArray = split(trim(rs("Notes")) & "", ";")
235 If ubound(varCampArray) > 0 Then
236 varCampArray2 = split(varCampArray(0) & "", "=")
237 End If
238 if ubound(varCampArray2) > 0 then
254 wend
Run Code Online (Sandbox Code Playgroud)
第 239-253 行无关紧要(只是基于数组和另一个查询的计算),只是想添加 'wend' 语句,所以没有人认为它没有正确编码。
额外信息:这是针对我们的自定义 vb 应用程序,对于这个特定的 asp 文件,用户转到 Report>Daily>Summary,然后用户从那里选择某一天以获取当天的财务摘要。如果我今天运行报告,它会运行并得到数字,如果我在本月 26 日运行它,它会运行并没有错误地执行。如果我昨天(4/27/2016)运行它,我会在我们的 vb 应用程序的 reportViewer 中得到这个:(Microsoft VBScript 运行时错误“800a000d”)
类型不匹配:'ubound'
/apps/Program14/reports/trans_summary.asp,第 238 行
我还没有尝试解决这个问题,因为我不确定如何处理这个问题。我什至查看了 iis 日志文件,它的错误是 500 0 0 130。然后配置 IE 以在运行时正确显示错误的详细信息。这就是它吐出来的东西,目前我被卡住了。任何帮助将不胜感激。我在谷歌上搜索并阅读了无数其他文章,但我仍然对这个问题感到有些茫然,而微软与外国技术支持一样有帮助。
什么时候ubound(varCampArray)没有>0,会有什么varCampArray2?它可能不是一个数组。这就是UBound方法 onvarCampArray2抛出错误的原因!
在使用 UBound 之前检查它是否是数组。
while not rs.eof
varCampArray = split(trim(rs("Notes")) & "", ";")
If ubound(varCampArray) > 0 Then
varCampArray2 = split(varCampArray(0) & "", "=")
End If
If isArray(varCampArray2) Then
if ubound(varCampArray2) > 0 then
'do something here
end If
Else
Msgbox "all these time i thought it was an array!!!"
End If
wend
Run Code Online (Sandbox Code Playgroud)
或者简单地说,您可以在第一个 if 块中移动第二个 if 。
while not rs.eof
varCampArray = split(trim(rs("Notes")) & "", ";")
If ubound(varCampArray) > 0 Then
varCampArray2 = split(varCampArray(0) & "", "=")
if ubound(varCampArray2) > 0 then
'do something here
end If
End If
wend
Run Code Online (Sandbox Code Playgroud)