经典ASP脚本导致'类型不匹配'新服务器上的错误

时间:2017-04-27 16:44:05

标签: mysql asp-classic type-mismatch

我刚刚被迫将论坛从旧的Windows 2002服务器重新定位到2012年的新服务器。

这是一个古老的经典ASP论坛(snitz),是' vanilla'多年来一直幸福地工作。

在计算出新的连接字符串以使MySql在此服务器上连接之后,论坛现在在其真正不应该的地方抛出以下错误

  

Microsoft VBScript运行时错误' 800a000d'

     

类型不匹配

     

/forum/inc_moderation.asp,第74行

它似乎是在检查数值(从DB查询分配给变量)的位置。以下是上例中的函数:

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行是:如果PostCount = 0则

为什么会导致类型不匹配?它不仅仅是这个脚本 - 我设法通过修改一个“修剪”来解决这个问题。在PostCount上(将其更改为):

if trim(PostCount) = 0 then

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

我已尽最大努力寻找,但无法找到其他任何可以尝试的东西。 (我发现最接近的是这个主题:iis7, classic asp; type mismatch error但我无法看到如何使其适用于我的配置)

1 个答案:

答案 0 :(得分:3)

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

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

要了解我是如何达到此修复程序并更好地了解出现问题的原因,请参阅我原始帖子上的评论主题(简而言之,看起来数据库正在从数据库中返回一个奇怪的vartype? COUNT语句无法与整数进行比较。这似乎是一个ODBC驱动程序问题,因为较旧的驱动程序已修复此问题。)