Solved

How to get this script working??? Got it working in ColdFusion, now the trick is to get it working in ASP.

Posted on 2001-07-27
12
181 Views
Last Modified: 2013-12-16
<script language="VbScript" runat="server">
dim rsAnk
Set rsAnk= Server.CreateObject("ADODB.Recordset")
sAnk = "Select * FROM menu_items ORDER BY menu_no"
rsAnk.Open sAnk, Con, adOpenStatic, adLockOptimistic

While Not rsAnk.eof
     response.write "<script>oCMenu.makeMenu('" & rsAnk(1) & "', '" & rsAnk(2) & "', '" & rsAnk(1) & "', '', '')<\/script>"
     rsAnk.moveNext
Wend

rsAnk.close
Set rsAnk=nothing
</script>

The problem here is that the above piece of code ios not working. It keeps repeating :

<b>A script block cannot be placed inside another script block.</b>

I have spent or you might say wasted a lot of time in figuring this out but I guess the solution has just eluded me. I would give anything for a working solution... Anyone who has been through this path knows the condition I am in. I am not able to get any peace because of this... The same thing is working in ColdFusion (with a minor adjustments) but not in ASP. Tried a lot of possible solutions but am unable to get it to work...

Any help on the above would be welcome... Thanks in advance... :):):) Have a nice day...

Joyriderank.
0
Comment
Question by:joyriderank
  • 3
  • 3
  • 2
  • +3
12 Comments
 
LVL 11

Expert Comment

by:thunderchicken
Comment Utility
Shouldn't

    response.write "<script>oCMenu.makeMenu('" & rsAnk(1) & "', '" & rsAnk(2) & "', '" & rsAnk(1) &
"', '', '')<\/script>"

Be

    response.write "<script>" & oCMenu.makeMenu('" & rsAnk(1) & "', '" & rsAnk(2) & "', '" & rsAnk(1) &
"', '', '')" & "<\/script>"
0
 
LVL 3

Accepted Solution

by:
Maxim10553 earned 300 total points
Comment Utility
well the first thing is that I dont see your ADO Connection anywhere, so what is the variable Con pointing to when you open your recordset?You would have to define it somewhat simialar to the following

Dim Con
Set Con = Server.CreateObject("ADODB.Connection")
Con.open ("Driver={SQL Server};Server=172.20.20.6;UID=sa;Pwd=password1")

at the beginning get rid of
<script language="VbScript" runat="server"> and use <%
and at the end get rid of </script> and use %>

in the middle of your script take out <script> and <Vscript>.
and what is oCMenu.makeMenu? again i dont see you declaring oCMenu anywhere in the script. If you are just trying to output the recordset to the screen use Response.Write instead of oCMenu.makeMenu
0
 
LVL 2

Expert Comment

by:DirkVe
Comment Utility
Change the first script block into <% %>

Code looke like this:

<!-- include file="adovbs.inc" -->
<%
dim rsAnk
Set rsAnk= Server.CreateObject("ADODB.Recordset")
sAnk = "Select * FROM menu_items ORDER BY menu_no"
rsAnk.Open sAnk, Con, adOpenStatic, adLockOptimistic

While Not rsAnk.eof
    response.write "<script>oCMenu.makeMenu('" & rsAnk(1) & "', '" & rsAnk(2) & "', '" & rsAnk(1) & "', '', '')<\/script>"
    rsAnk.moveNext
Wend

rsAnk.close
Set rsAnk=nothing
%>

0
 
LVL 2

Expert Comment

by:DirkVe
Comment Utility
Change the first script block into <% %>

Code looke like this:

<!-- include file="adovbs.inc" -->
<%
dim rsAnk
Set rsAnk= Server.CreateObject("ADODB.Recordset")
sAnk = "Select * FROM menu_items ORDER BY menu_no"
rsAnk.Open sAnk, Con, adOpenStatic, adLockOptimistic

While Not rsAnk.eof
    response.write "<script>oCMenu.makeMenu('" & rsAnk(1) & "', '" & rsAnk(2) & "', '" & rsAnk(1) & "', '', '')<\/script>"
    rsAnk.moveNext
Wend

rsAnk.close
Set rsAnk=nothing
%>

0
 
LVL 2

Expert Comment

by:DirkVe
Comment Utility
The code above will solve you're script problem.
To have completely working code, you need of course declare and open your connection (= named Con in your code), but I guess you did it? In case you didn't, look at the comment from Maxim10553 .
0
 
LVL 33

Expert Comment

by:hongjun
Comment Utility
Try this
I am assuming you are using access. Change the connection string of Con accordingly.

<%@Language=VBScript%>

<%
dim Con, rsAnk, sAnk

set Con = Server.CreateObject("ADODB.Connection")
Con.Open "Driver={Microsoft Access Driver (*.mdb)};dbq=" & Server.MapPath("your_db.mdb") & ";uid=sa;pwd=;"
sAnk = "Select * FROM menu_items ORDER BY menu_no"
set rsAnk = Con.Execute(sAnk)



While Not rsAnk.eof
    response.write "<script>oCMenu.makeMenu('" & rsAnk(1) & "', '" & rsAnk(2) & "', '" & rsAnk(1) & "', '', '')<\/script>"
    rsAnk.moveNext
Wend

Con.close
Set rsAnk=nothing
set Con = nothing
%>

hongjun
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 

Expert Comment

by:venkatesan_ram
Comment Utility
hey
 instead of that script tag use the delimiter
<%, do asusual the ado connection method.script tag will give the functionality of jscript
0
 
LVL 33

Expert Comment

by:hongjun
Comment Utility
venkatesan_ram,

Welcome to EE. The policy here is to post everyhing in comments. Questionner will then have the option to accept a comment as an answer. Posting as a proposed answer will lock the question and thus restrict the exposure to more experts. We know you are new here and thus is forgiven. With the current version of EE, you do not have the option to convert your answer to a comment but this can be done by the questioner himself. I advise the questionner to reject his answer so that this question will be released to more experts. You can however accept his comment again if you find it is really helpful.

Thanks
hongjun
0
 
LVL 1

Author Comment

by:joyriderank
Comment Utility
Sorry venkatesan_ram@devx's, but I guess other's have already answered my question and you giving your's as an answer does not makes theirs wrong. So I am going to give the points to the first person who I think got the answer correct.
0
 
LVL 33

Expert Comment

by:hongjun
Comment Utility
So who is the one?

hongjun
0
 
LVL 1

Author Comment

by:joyriderank
Comment Utility
Thanks everyone for coming to my aid. But the best part is that I got it figured all by my self. And yes I did it the same way as you guys suggested. The thing was that maybe I was trying a bit too hard to solve the problem and I guess in giving it so much thought I guess I just forgot the basics to get it done. All I did was sleep at night thinking about it and decided to remove the script tags and use <% %> the delimeters instead of the <script> tags and Voila in the morning it was working fine. I would like to thank everyone again. I guess everyone was right but I can give the points to only one person. And the first person who I think got to the answer of the problem was Maxim10553, so I am going to give the points to him.

For anyone curious enough to see how the final code looks like here it is :

<%
dim rsAnk
Set rsAnk= Server.CreateObject("ADODB.Recordset")
sAnk = "Select * FROM menu_items ORDER BY menu_no"
rsAnk.Open sAnk, Con, adOpenStatic, adLockOptimistic

While Not rsAnk.eof %>

     oCMenu.makeMenu('<%= rsAnk(1) %>', '<%= rsAnk(2) %>', '<%= rsAnk(1) %>', '', '')

<%     rsAnk.moveNext
Wend

rsAnk.close
Set rsAnk=nothing
%>
0
 

Expert Comment

by:venkatesan_ram
Comment Utility
hai
   really i am sorry , ok i understood. thanks
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Now that Expression Web 4.0 (http://www.microsoft.com/expression/products/Upgrade.aspx) is free if you buy or have the full version of Expression Web 3.0, now is the best time to  migrate from FrontPage to Expression Web (http://www.frontpage-to-exp…
Objective of This Article In 1990’s, when I was a budding software professional, I had a lot of confusion about which stream or technology, I had to choose to build my career. In those days, I had lot of confusion like whether to choose System so…
The purpose of this video is to demonstrate how to reset a WordPress password if you are locked out and cannot reset the password. A typical use would be if you cannot access the email to which WordPress would send the password recovery email to…
The purpose of this video is to demonstrate how to set up an RSS Feed on a WordPress Website. This will be demonstrated using a Windows 8 PC. Feedburner will be used for this demonstration. Go to your WordPress login page. This will look like the…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now