Never mind, was able to figure it out.
The problem was that I had my strSQL2 and objRS2 variables declared on a global level, once I put them in the sub it works like a charm.
=======================
Hi guys,
little bit of background on this project. I'm using the script located
here
to generate some menus.
My version can be seen
here
I have now moved it to the server at work, and am modifying the script to work with some libraries we have set up here. We use a disconnected recordset function to grab our queries, and this is where I'm running into the problem.
I am getting an "object required" error when I call the Sub again a second time. My guess is that the rs is not being reopened again but I'm not sure why. I have put the text in bold where it's failing.
some of the original code is still in there, I've left it for now, but it's commented out. I don't need it because my disconnected recordset function should be doing all of it.
Code:
Sub listSubCat(MenuID)
strSQL2 = "SELECT menuCat.MenuID, menuCat.MenuName, menuCat.isParent, menuCat.MenuLink FROM menuCat" &_
" INNER JOIN menuSubCat ON menuCat.MenuID = menuSubCat.MenuID" &_
" WHERE menuSubCat.SubMenuID = " & MenuID &_
" ORDER BY menuCat.SortOrder"
set objRS2 = GetDisconnectedRecordset(strSQL2, "GetChildMenus", false)
'Set SubCat = Server.CreateObject("ADODB.Recordset")
'SubCat.ActiveConnection = MM_MenuSystem_STRING
'SubCat.Source = sql
'SubCat.CursorType = 0
'SubCat.CursorLocation = 2
'SubCat.LockType = 1
'objRS2.Open()
If Not objRS2.EOF Or Not objRS2.BOF Then
Response.Write "<ul class=""second_lvl"">" & vbCRLF
While NOT objRS2.EOF
'Indented Response.Write indicates optional output
Response.Write "<li "
if (objRS2("isParent") = "True") then
response.write "class=""next_arrow"" "
end if
Response.write ">"
if (objRS2("MenuLink") <> "") then
Response.Write "<a href="""&objRS2("MenuLink")&""">" &objRS2("MenuName")&"</a>"
else
Response.Write "<a href=""#"">" &objRS2("MenuName")&"</a>"
end if
Response.Write vbCRLF
Call listSubCat(objRS2("MenuID"))
Response.Write "</li>" & vbCRLF
'Code fails here
objRS2.MoveNext()
Wend
Response.Write "</ul>" & vbCRLF
End If
objRS2.Close()
Set objRS2 = Nothing
End Sub
If I comment out objRS2.Close() and set objRS2 = Nothing, then I get the following error on the same line as above.
Quote:
Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record. |