经典 ASP 数组不返回值,错误 500

发布于 2024-12-09 06:55:57 字数 1669 浏览 0 评论 0原文

我正在努力多次执行相同的代码来生成一个表。我的第一个想法是使用数组来做到这一点。

这是我到目前为止所得到的:

Dim iRow
iRow = 0 

'alternate color for rows   
Do While Not rsGlobalWeb.EOF 
If iRow Mod 2 = 0 Then 
    response.write "<tr bgcolor=""#FFFFFF"">"
Else 
    response.write "<tr bgcolor=""#EEEEEE"">"
End If 

'some other code
SqlBackup = "SELECT * FROM CMDBbackup WHERE Naam_Cattools = '" & rsGlobalWeb("Device_name") & "'" 
Set rsBackup = Server.CreateObject("ADODB.Recordset")
rsBackup.Open SqlBackup, dbGlobalWeb, 3     

'declaration of array
Dim fieldname(5),i
fieldname(0) = "Device_name"
fieldname(1) = "Image"
fieldname(2) = "Backup"
fieldname(3) = "Uptime"
fieldname(4) = "Processor"
fieldname(5) = "Nvram"

For i = 0 to 5
    If rsGlobalWeb(fieldname(i)) <> "" Then
        response.write("<td>" & rsGlobalWeb(fieldname(i)) & "</td>")
    Else
        If Not rsBackup.EOF Then
            If Not IsNull(rsBackup(fieldname(i))) And (rsBackup(fieldname(i)) <> "") Then
                response.write("<td>" & rsBackup(fieldname(i)) & " (backup)</td>")
            End if
        Else
            response.write("<td>No data found</td>")
        End if
    End if  
Next

response.write("</tr>")

iRow = iRow + 1
rsGlobalWeb.MoveNext 
Loop

我现在遇到的问题是,即使我关闭了友好消息,也会出现以下错误:

“500 - 内部服务器错误。 您正在查找的资源有问题,无法显示。”

日志文件显示以下内容: “DaEngineSDB.asp |58|800a000d|Type_mismatch 80 -” 其中 58 是包含 Dim Fieldname 的行。

如果没有数组,它确实会显示代码的其余部分(我还有 1 个其他字段被添加)。如果我删除数组并用普通字符串值填充字段名(i),它也可以正常工作。

我正在尝试谷歌所说的东西,但在尝试了几件事之后,我仍然遇到了困难。 有什么想法吗?

预先感谢,

埃里克

I'm working on executing the same code several times to produce a table. My first thoughts went out to using an array to do this.

Here is what i have got so far:

Dim iRow
iRow = 0 

'alternate color for rows   
Do While Not rsGlobalWeb.EOF 
If iRow Mod 2 = 0 Then 
    response.write "<tr bgcolor=""#FFFFFF"">"
Else 
    response.write "<tr bgcolor=""#EEEEEE"">"
End If 

'some other code
SqlBackup = "SELECT * FROM CMDBbackup WHERE Naam_Cattools = '" & rsGlobalWeb("Device_name") & "'" 
Set rsBackup = Server.CreateObject("ADODB.Recordset")
rsBackup.Open SqlBackup, dbGlobalWeb, 3     

'declaration of array
Dim fieldname(5),i
fieldname(0) = "Device_name"
fieldname(1) = "Image"
fieldname(2) = "Backup"
fieldname(3) = "Uptime"
fieldname(4) = "Processor"
fieldname(5) = "Nvram"

For i = 0 to 5
    If rsGlobalWeb(fieldname(i)) <> "" Then
        response.write("<td>" & rsGlobalWeb(fieldname(i)) & "</td>")
    Else
        If Not rsBackup.EOF Then
            If Not IsNull(rsBackup(fieldname(i))) And (rsBackup(fieldname(i)) <> "") Then
                response.write("<td>" & rsBackup(fieldname(i)) & " (backup)</td>")
            End if
        Else
            response.write("<td>No data found</td>")
        End if
    End if  
Next

response.write("</tr>")

iRow = iRow + 1
rsGlobalWeb.MoveNext 
Loop

The issue i have now is that the following error occurs even tho i have friendly messages turned off:

"500 - Internal server error.
There is a problem with the resource you are looking for, and it cannot be displayed."

The logfile shows the following:
"DaEngineSDB.asp |58|800a000d|Type_mismatch 80 -" Where the 58 is the line with the Dim Fieldname.

Without the array it does show the remainder of the code (i have 1 other field which gets added). If i remove the array and fill the fieldname(i) with a normal string value it also works fine.

I was trying out stuff that google says but after attempting several things i am still running up to a wall.
Any ideas what it could be?

Thanks in advance,

Erik

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

他是夢罘是命 2024-12-16 06:55:57

首先,您应该在 iis 中打开错误显示,或者阅读错误日志以获取其描述,如果不确定如何,请用 google 搜索。

如果没有错误描述,就很难检查错误所在。

First you should turn on error displaying in your iis, or read the error log for its description, google it if not sure how.

Without error description, it's way too difficult to check what is wrong.

谜兔 2024-12-16 06:55:57

问题解决了!

在我用头撞墙一天后,我发现我愚蠢地在 DO WHILE 循环内声明了数组。将声明移出并解决问题。

Problem solved!

After banging my head against the wall for a day i found out that i stupidly declared the array inside the DO WHILE loop. Moved the declaration out of it and problem solved.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文