Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Operation is not allowed when the object is open

Status
Not open for further replies.

ufobaby

MIS
Sep 25, 2001
238
US
am using SQL 2000 and ASP the below code gives an error

set rsMnuTop = Server.CreateObject("Adodb.recordset")
set rsMnuLvl = Server.CreateObject("Adodb.recordset")

rsMnuTop.open "select * from menumaster where typ_top='Y' and mnu_Pindex=0 and mnu_Nindex=0",con,adOpenDynamic

do until rsMnuTop.EOF = true

response.write rsMnuTop("txt_mnuname")

'---- ERROR
rsMnuLvl.open "select * from menumaster where cod_mnuId =" & rsMnuTop("cod_mnuId")& "",con,adOpenDynamic
'---- ERROR
do until rsMnuLvl.EOF = true
response.write "-" & rsMnuLvl("txt_mnuname")
rsMnuLvl.MoveNext
loop

ctr = ctr +1
rsMnuTop.MoveNext

loop


Pls help

__________
[cheers]
Niraj...
"The unexpected success is not just an opportunity for innovation. It demands innovation."
[noevil]
 
YOu need to close the object after you done before looping through again. add this to your code just above the loop

rsMnuLvl.close

Let me know

Cassidy
 
Code:
do until rsMnuTop.EOF = true
  response.write rsMnuTop("txt_mnuname")
     rsMnuLvl.open "select * from menumaster where cod_mnuId =" & rsMnuTop("cod_mnuId")& "",con,adOpenDynamic
       do until rsMnuLvl.EOF = true
          response.write "-" & rsMnuLvl("txt_mnuname")
          rsMnuLvl.MoveNext
       loop
       [b]rsMnuLvl.Close[/b]
   rsMnuTop.MoveNext
loop

try that

___________________________________________________________________

The answer to your ??'s may be closer then you think. faq333-3811
Join the Northern Illinois/Southern Wisconsin members in Forum1064
 
actually that just looks horrid

this may be a bit more optimized
Code:
set rsMnuTop = Server.CreateObject("Adodb.recordset")
rsMnuTop.open "select * from menumaster where typ_top='Y' and mnu_Pindex=0 and mnu_Nindex=0",con,adOpenDynamic

do until rsMnuTop.EOF = true
  response.write rsMnuTop("txt_mnuname")
     Set rsMnuLvl = con.Execute("select * from menumaster where cod_mnuId =" & rsMnuTop("cod_mnuId"))
       do until rsMnuLvl.EOF = true
          response.write "-" & rsMnuLvl("txt_mnuname")
          rsMnuLvl.MoveNext
       loop
   rsMnuTop.MoveNext
loop

sorry Cassidy -- posted at the same time first round

___________________________________________________________________

The answer to your ??'s may be closer then you think. faq333-3811
Join the Northern Illinois/Southern Wisconsin members in Forum1064
 
and once again I need to add

the tables are obviously related by ID so why aren't you joining them??

___________________________________________________________________

The answer to your ??'s may be closer then you think. faq333-3811
Join the Northern Illinois/Southern Wisconsin members in Forum1064
 
Thank u all, actuall me jus getting back to some coding...

Thx once again

__________
[cheers]
Niraj...
"The unexpected success is not just an opportunity for innovation. It demands innovation."
[noevil]
 
onpnt, thx

this is my table
cod_mnuId txt_mnuname mnu_Pindex mnu_Nindex txt_page typ_top
1 Upload 0 0 upl.asp Y
2 CPC 1 3 cpc.asp Y
3 IBBS 1 4 ibbs.asp N
4 Vendor 1 5 vend.asp N
5 Os Det 2 0 os.asp N
6 Reports 0 0 rep.asp Y
7 Rep1 6 8 rep1.asp N
8 Rep2 6 0 rep2.asp N

this is one single table and i want to do a recurssive search on this till i get all the levels of a menu

any ideas ?

Thanks

__________
[cheers]
Niraj...
"The unexpected success is not just an opportunity for innovation. It demands innovation."
[noevil]
 
didn't notice they were the same table...

ORDER BY should do it.

Code:
SELECT * 
FROM menumaster 
WHERE typ_top='Y' 
AND mnu_Pindex=0 
AND mnu_Nindex=0
ORDER BY cod_mnuId

If I understand correctly of what you are doing.

Also, always SELECT only the fields you need in SQL SELECT's. it kills peformance if you just * them

___________________________________________________________________

The answer to your ??'s may be closer then you think. faq333-3811
Join the Northern Illinois/Southern Wisconsin members in Forum1064
 
can you explain what you're doing in there. doesn't make much sense sense that ID must be unique and you should only have one entry for it

___________________________________________________________________

The answer to your ??'s may be closer then you think. faq333-3811
Join the Northern Illinois/Southern Wisconsin members in Forum1064
 
actually am jus trying, and hence using *...
but the problem is : am trying to biuld a generic menu heirarchy into the table and then retrieve it using the code so some menu in DHTML can be made

the current table represents the MENU

UPLOAD
|__CPC
|__Os Det
|__IBBS
|__Vendor
Reports
|__Rep1
|__Rep2

hope am able to explain the situation, by maintaining i can have any levels of menu, but i should also be able ti retrieve the same.

Thanks

__________
[cheers]
Niraj...
"The unexpected success is not just an opportunity for innovation. It demands innovation."
[noevil]
 
so mnu_Pindex relates to cod_mnuId in the same table??

sorry man, that's horrid. is it possible to create another table so the thing is normalized at least a little bit?

otehr wise you're looking at a very poor performing app

___________________________________________________________________

The answer to your ??'s may be closer then you think. faq333-3811
Join the Northern Illinois/Southern Wisconsin members in Forum1064
 
would not really help, because in the current example under the menu CPC there is only one item which is Os Det , what if under Os Det there is another one ....

CPC
|__Os Det
|__Level 2

would not be able to go on creating tables. gues this should be possible ! .. don't know how.

__________
[cheers]
Niraj...
"The unexpected success is not just an opportunity for innovation. It demands innovation."
[noevil]
 
after some goo amount of research i figured out that there is no other way but to write a recursive function for this.... some problem still .......

<%
'Sample to get the menu hierarchy
set rsMnuTop = Server.CreateObject("Adodb.recordset")
set rsMnuLvl = Server.CreateObject("Adodb.recordset")

Function rec(Pind,Lvl)

---- ERROR
rsMnuTop.Open "select * from menumaster where mnu_Pindex=" & Pind,con,adOpenDynamic
---- ERROR
do until rsMnuTop.EOF = true

response.write rsMnuTop("cod_mnuId") & " - " & rsMnuTop("txt_mnuname") & " - " & Lvl

call rec rsMnuTop(0), Lvl + 1
rsMnuTop.MoveNext

loop
rsMnuTop.Close

End Function

call rec 0,0
%>

i still get this error, only when executed through the wep page i.e ASP, the same code works fine in Visual Basic....

Pls Pls help am stuck :(

__________
[cheers]
Niraj...
&quot;The unexpected success is not just an opportunity for innovation. It demands innovation.&quot;
[noevil]
 
Try this:

Code:
rsMnuTop.Open "select * from menumaster where mnu_Pindex=" & Pind,con,1,3

I know I have problems using adOpenDynamic in ASP even though it works great in VB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top