经典 ASP 脚本在新服务器上导致 'Type mismatch' 错误

Classic ASP script causing 'Type mismatch' error on new server

我刚刚被迫将论坛从旧的 Windows 2002 服务器迁移到新的 2012 服务器。

老经典ASP论坛(snitz)'vanilla',已经愉快工作多年

在弄清楚新的连接字符串 MySql 以连接到此服务器后,论坛现在在不应该

的地方抛出以下错误

Microsoft VBScript runtime error '800a000d'

Type mismatch

/forum/inc_moderation.asp, line 74

它似乎是在检查数值(分配给来自数据库查询的变量)的地方。这是上面示例中的函数:

function CheckForUnmoderatedPosts(CType, CatID, ForumID, TopicID)
    Dim PostCount
    PostCount = 0
    if strModeration > 0 then
        ' Check the Topics Table first
        strSql = "Select Count(*) as PostCount"
        strSql = strSql & " FROM " & strTablePrefix & "TOPICS T"
        if CType = "CAT" then
            strSql = strSql & " WHERE T.CAT_ID = " & CatID & " AND T.T_STATUS > 1 "
        elseif CType = "FORUM" then
            strSql = strSql & " WHERE T.FORUM_ID = " & ForumID & " AND T.T_STATUS > 1 "
        elseif CType = "TOPIC" then
            strSql = strSql & " WHERE T.TOPIC_ID = " & TopicID & " AND T.T_STATUS > 1 "
        elseif CType = "POSTAUTHOR" then
            strSql = strSql & " WHERE T.T_AUTHOR = " & MemberID & " AND T.T_STATUS > 1 AND T.TOPIC_ID = " & TopicID
        end if
        if CType = "BOARD" then
            strSql = strSql & ", " & strTablePrefix & "CATEGORY C"
            strSql = strSql & ", " & strtablePrefix & "FORUM F"
            ' This line makes sure that moderation is still set in the Category
            strSql = strSql & " WHERE T.CAT_ID = C.CAT_ID AND C.CAT_MODERATION > 0"
            ' This line makes sure that moderation is still set to all posts or topic in the Forum
            strSql = strSql & " AND T.FORUM_ID = F.FORUM_ID AND F.F_MODERATION in (1,2)" & " AND T.T_STATUS > 1 "
        end if
        set rsCheck = my_Conn.Execute(strSql)
        if not rsCheck.EOF then
            PostCount = rsCheck("PostCount")
        else
            PostCount = 0
        end if
        if PostCount = 0 then
            ' If no unmoderated posts are found on the topic table, check the replies.....
            strSql = "Select Count(*) as PostCount"
            strSql = strSql & " FROM " & strTablePrefix & "REPLY R"
            if CType = "CAT" then
                strSql = strSql & " WHERE R.CAT_ID = " & CatID & " AND R.R_STATUS > 1 "
            elseif CType = "FORUM" then
                strSql = strSql & " WHERE R.FORUM_ID = " & ForumID & " AND R.R_STATUS > 1 "
            elseif CType = "TOPIC" then
                strSql = strSql & " WHERE R.TOPIC_ID = " & TopicID & " AND R.R_STATUS > 1 "
            elseif cType = "POSTAUTHOR" then
                strSql = strSql & " WHERE R.R_AUTHOR = " & MemberID & " AND R.R_STATUS > 1 AND R.TOPIC_ID = " & TopicID
            end if
            if CType = "BOARD" then
                strSql = strSql & ", " & strTablePrefix & "CATEGORY C"
                strSql = strSql & ", " & strtablePrefix & "FORUM F"
                ' This line makes sure that moderation is still set in the Category
                strSql = strSql & " WHERE R.CAT_ID = C.CAT_ID AND C.CAT_MODERATION > 0"
                ' This line makes sure that moderation is still set to all posts or reply in the Forum
                strSql = strSql & " AND R.FORUM_ID = F.FORUM_ID AND F.F_MODERATION in (1,3)" & " AND R.R_STATUS > 1 "
            end if
            rsCheck.close
            set rsCheck = my_Conn.Execute(strSql)
            if not rsCheck.EOF then
                PostCount = rsCheck("PostCount")
            else
                PostCount = 0
            end if
        end if
        rsCheck.close
        set rsCheck = nothing
    end if
    CheckForUnModeratedPosts = PostCount
end function

第 74 行是:if PostCount = 0 then

为什么会导致类型不匹配?不仅仅是这个脚本——我设法通过在 PostCount 上放置一个 'trim' 来修复这个脚本(因此将其更改为):

if trim(PostCount) = 0 then

修复了它,但随后(许多)其他脚本导致了同样的问题。

我已尽我所能进行搜索,但找不到其他可尝试的内容。 (我找到的最接近的是这个线程:iis7, classic asp; type mismatch error 但我看不出如何使它适用于我的配置)

回滚到 5.1 并使用以下连接字符串解决了问题:

"driver=MySQL ODBC 5.1 Driver;option=16387;server=localhost;uid=xxxxxxx;pwd=yyyyyyy;database=zzzzzzz"

要了解我是如何解决此问题并更好地了解出了什么问题,请参阅我原来的评论线程 post(简而言之,看起来数据库从无法与整数进行比较的数据库的 COUNT 语句。这似乎是一个 ODBC 驱动程序问题,因为较旧的驱动程序已修复此问题)