Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
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
Medium Priority
?
189 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 900 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
NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

 
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

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.

Question has a verified solution.

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

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 informatio…
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
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 Import and export files in WordPress. 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 : Click on Too…

730 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