Reputation: 287
I recently had to migrate an (inherited) old Classic ASP VBScript reporting website from a windows server 2003 to windows server 2012.
After messing about with the AppPool to make it use 32bit mode, and also set up parent paths, I've been able to get the application to work.
However, the following page is currently throwing this error:
Microsoft VBScript runtime error '800a01a8' Object required: '' /Dashboard/modules/Monthly_Report/footfall/Save_Session_Variables_Stock.asp, line 69
The code behind the page is
<!--#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"
%>
When tracing the SQL query, I can execute the same SELECT without any visible issues.
Would anyone have any ideas as to why this could be failing?
Upvotes: 0
Views: 1855
Reputation: 16672
Without going into how to structure your code etc, it is a simple enough fix.
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
By moving the rsGet_Market.close
inside the Case statement it will only be called when there is a corresponding ADODB.Recordset
in the rstGet_Market
object.
You can't Close a Recordset that never exists in the first place.
We could improve on this though by moving the instantiation outside of the Case statement to remove yet more duplication (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
Upvotes: 1
Reputation: 2940
Correction, line 71 is rsGet_Market.close
OK. Let's take a look closer to your code.
You calling rsGet_Market.close
always, but create it only for Case 1 and Case 4. Perhaps you have CINT(Session("SITE_LVL")) not equal to 1 and not equal to 4.
but that doesn't generate any data.
Yes, but you always calling method (function) for not existing object (Set
create it in your case for rsGet_Market). That why you have error Object required: ''
Upvotes: 1