Windows Server 2012 / IIS8中的经典ASP错误

时间:2015-07-17 10:51:24

标签: vbscript asp-classic windows-server-2012 iis-8

我最近不得不将(继承的)旧的经典ASP VBScript报告网站从Windows Server 2003迁移到Windows Server 2012。

在弄乱AppPool使其使用32位模式,并设置父路径后,我已经能够使应用程序正常工作。

但是,以下页面目前正在抛出此错误:

Microsoft VBScript runtime error '800a01a8'

Object required: ''

/Dashboard/modules/Monthly_Report/footfall/Save_Session_Variables_Stock.asp, line 69

页面背后的代码是

<!--#include file="../../../../Connections/Dashboard_Connection.asp" -->
<%
Session.LCID=2057
'Session("strMonthly_Site")=trim(request("select_site"))
''xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
'Set the search screen variables to be nothing
Session("strCategory_Lookup")=""
Session("strSearch_String")=""

'*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
'Get the market code based on the site
'*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
DIM rsGet_Market
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open strConnection

'Get the Site Level_Code
Session("SITE_LVL") = MID(Session("strMonthly_Site"),INSTR(Session("strMonthly_Site"),",")+ 1, 2)
Session("SITE_LVL_CODE") = LEFT(Session("strMonthly_Site"),INSTR(Session("strMonthly_Site"),",")-1)

SELECT CASE CINT(Session("SITE_LVL"))

CASE 1 'Site

strQuery = "SELECT SITE_MARKET.MARKET_CODE, SITE_MARKET.MARKET_TEXT, SITE_ZONE.ZONE_CODE, SITE_ZONE.ZONE_TEXT, SITE_AREA.AREA_CODE, SITE_AREA.AREA_TEXT, SITE.SITE_CODE, SITE.SITE_TEXT " & _
            "FROM SITE_REGION INNER JOIN SITE_MARKET ON SITE_REGION.REGION_CODE = SITE_MARKET.REGION_CODE INNER JOIN SITE INNER JOIN SITE_AREA ON SITE.AREA_CODE = SITE_AREA.AREA_CODE " & _
            "INNER JOIN SITE_ZONE ON SITE_AREA.ZONE_CODE = SITE_ZONE.ZONE_CODE ON SITE_MARKET.MARKET_CODE = SITE_ZONE.MARKET_CODE " & _ 
            "WHERE SITE.SITE_CODE = '" & Session("SITE_LVL_CODE") & "'"

Set rsGet_Market = Server.Createobject("ADODB.Recordset")
rsGet_Market.Open strQuery, objConn

Session("Market_Market_Code") = rsGet_Market("MARKET_CODE") & " - " & rsGet_Market("MARKET_TEXT")
Session("Market_Zone_Code") = rsGet_Market("ZONE_CODE") & " - " & rsGet_Market("ZONE_TEXT")
Session("Market_Area_Code") = rsGet_Market("AREA_CODE") & " - " & rsGet_Market("AREA_TEXT")
Session("Market_Site_Code") = rsGet_Market("SITE_CODE") & " - " & rsGet_Market("SITE_TEXT")
Session("MARKET_CODE") = rsGet_Market("MARKET_CODE")

Session("Market_Market_Code1") = rsGet_Market("MARKET_TEXT")
Session("Market_Zone_Code1") = rsGet_Market("ZONE_TEXT")
Session("Market_Area_Code1") = rsGet_Market("AREA_TEXT")
Session("Market_Site_Code1") = rsGet_Market("SITE_CODE") & " - " & rsGet_Market("SITE_TEXT")
Session("Table_Lvl_Label") = "Shop"

CASE 4 'Market

strQuery = "SELECT SITE_MARKET.MARKET_CODE, SITE_MARKET.MARKET_TEXT, SITE_ZONE.ZONE_CODE, SITE_ZONE.ZONE_TEXT, SITE_AREA.AREA_CODE, SITE_AREA.AREA_TEXT, SITE.SITE_CODE, SITE.SITE_TEXT " & _
            "FROM SITE_REGION INNER JOIN SITE_MARKET ON SITE_REGION.REGION_CODE = SITE_MARKET.REGION_CODE INNER JOIN SITE INNER JOIN SITE_AREA ON SITE.AREA_CODE = SITE_AREA.AREA_CODE " & _
            "INNER JOIN SITE_ZONE ON SITE_AREA.ZONE_CODE = SITE_ZONE.ZONE_CODE ON SITE_MARKET.MARKET_CODE = SITE_ZONE.MARKET_CODE " & _ 
            "WHERE SITE_MARKET.MARKET_CODE = '" & Session("SITE_LVL_CODE") & "'"

Set rsGet_Market = Server.Createobject("ADODB.Recordset")
rsGet_Market.Open strQuery, objConn

Session("Market_Market_Code") = rsGet_Market("MARKET_CODE") & " - " & rsGet_Market("MARKET_TEXT")
Session("Market_Zone_Code") = "N/A"
Session("Market_Area_Code") = "N/A"
Session("Market_Site_Code") = "N/A"
Session("MARKET_CODE") = rsGet_Market("MARKET_CODE")

Session("Market_Market_Code1") = rsGet_Market("MARKET_TEXT")
Session("Market_Zone_Code1") = "N/A"
Session("Market_Area_Code1") = "N/A"
Session("Market_Site_Code1") = "N/A"
Session("Table_Lvl_Label") = "Market"

END SELECT

rsGet_Market.close
objConn.Close
set rsGet_Market= Nothing
set objConn= Nothing
response.redirect "Footfall_Report.asp"
%>

在跟踪SQL查询时,我可以执行相同的SELECT而不会出现任何明显的问题。

有人会有任何关于为什么会失败的想法吗?

2 个答案:

答案 0 :(得分:1)

  

更正,第71行是rsGet_Market.close

行。我们来看看您的代码。

您总是调用rsGet_Market.close,但仅为案例1和案例4创建它。也许您有CINT(会话(&#34; SITE_LVL&#34;))不等于1且不等于4。

  

但这并不会产生任何数据。

是的,但是你总是为不存在的对象调用方法(函数)(Set在你的情况下为 rsGet_Market 创建它。这就是为什么你有错误需要对象:&#39;&#39;

答案 1 :(得分:1)

不考虑如何构建代码等,这是一个简单的修复。

SELECT CASE CINT(Session("SITE_LVL"))
CASE 1 'Site

    'Recordset instantiated here
    Set rsGet_Market = Server.Createobject("ADODB.Recordset")
    rsGet_Market.Open strQuery, objConn

    'Lots of fluff here removed to emphasize the point
    '...

    'Close Recordset inside the Case statement
    rsGet_Market.close

CASE 4 'Market

    'Recordset instantiated here
    Set rsGet_Market = Server.Createobject("ADODB.Recordset")
    rsGet_Market.Open strQuery, objConn

    'Lots of fluff here removed to emphasize the point
    '...

    'Close Recordset inside the Case statement
    rsGet_Market.close

END SELECT

'Don't close rsGet_Market here as it might not exist and cause an error.
objConn.Close

通过移动Case语句中的rsGet_Market.close,只有在ADODB.Recordset对象中存在相应的rstGet_Market时才会调用它。

  

您无法关闭一开始就不存在的Recordset。

我们可以通过在Case语句之外移动实例化来删除更多重复(DRY Principle

来改进这一点
'Recordset instantiated here
Set rsGet_Market = Server.Createobject("ADODB.Recordset")

SELECT CASE CINT(Session("SITE_LVL"))
CASE 1 'Site

    'Recordset will be open if data is returned.
    rsGet_Market.Open strQuery, objConn

    'Lots of fluff here removed to emphasize the point
    '...

    'Close Recordset inside the Case statement
    rsGet_Market.close

CASE 4 'Market

    'Recordset will be open if data is returned.
    rsGet_Market.Open strQuery, objConn

    'Lots of fluff here removed to emphasize the point
    '...

    'Close Recordset inside the Case statement
    rsGet_Market.close

END SELECT

'Release Recordset object from memory
Set rsGet_Market = Nothing

'Don't close rsGet_Market here as it might not exist and cause an error.
objConn.Close