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
187 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
  • +3
12 Comments
 
LVL 11

Expert Comment

by:thunderchicken
ID: 6326678
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
ID: 6326683
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
ID: 6326702
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
Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

 
LVL 2

Expert Comment

by:DirkVe
ID: 6326713
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
ID: 6326721
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
ID: 6326740
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
 

Expert Comment

by:venkatesan_ram
ID: 6326956
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
ID: 6327142
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
ID: 6329250
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
ID: 6329253
So who is the one?

hongjun
0
 
LVL 1

Author Comment

by:joyriderank
ID: 6329262
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
ID: 6337039
hai
   really i am sorry , ok i understood. thanks
0

Featured Post

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article provides a case study on how our local youth baseball league deployed a new website, including the platform selection, implementation and benefits to the league.
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 make a WordPress Site faster and smaller in size by cleaning up the database. This will be demonstrated using a Windows 8 PC. Plugin WP Optimize will be used. Go to your WordPress login page. T…
The purpose of this video is to demonstrate how to integrate Mailchimp with WordPress, by placing a Mailchimp signup form on a WordPress Page or Post. This will be demonstrated using a Windows 8 PC. Mailchimp will be used. Log into your Mailchi…

636 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