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
182 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
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
 
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
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Common Front Ends using Dynamics CRM 3 87
Dreamweaver server behavior gone 6 108
Adding Datediff to staistics page 2 49
PDF Embed pdfobject.js local path problem regular ASP 2 117
I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
The purpose of this video is to demonstrate how to add AdSense Ads to a WordPress Website, and how to set up WordPress to automatically place Ads in Sidebars. This will be demonstrated using a Windows 8 PC. Log into your AdSense account. : Cli…
The purpose of this video is to demonstrate how to set up the permalinks on a WordPress Website. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Go t…

919 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

21 Experts available now in Live!

Get 1:1 Help Now