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
186 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Select only the top record in a left join 13 50
Reg Exp to extract Url from string asp 12 58
Save data in two Database, Asp 2 69
Compress Newid value ms sql Mssql 4 47
Turn A Profile Picture Into A Cartoon Using Photoshop And Illustrator This tutorial will teach you how to make a cartoon style image out of a regular picture. I have tried to keep the tutorial as simple as possible. I used Adobe CS4 for this tuto…
This guide will walk you through the essential considerations and tech stack for building scalable websites. Know how to grow your business the smart way!
The purpose of this video is to demonstrate how to properly insert a Vimeo Video into a WordPress site or Blog. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp…
The purpose of this video is to demonstrate how to prevent comment spam on a WordPress Website. This will be demonstrated using a Windows 8 PC. Plugin Akismet will be used. Go to your WordPress login page. This will look like the following: myw…

739 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