Solved

using recordset data to populate url in hyperlink to pass information to next page, but buffer exceed error is appearing.

Posted on 2008-10-20
4
213 Views
Last Modified: 2013-11-16
this is my first real project working with asp and an existing database, and im still getting my head around things here.

i want to pass two pieces of information (selectedUnit and selectedSemester) from one asp page to the next (coordinator.asp to details.asp). 'coordinator.asp' generates a list of unitIDs from a database (based on a login from the previous page not shown), where each ID needs to link to 'details.asp', using the 'unitID' and 'semester' to populate it.

so if i am to dynamically create the url in which the hyperlink directs to with these two pieces of data attached, i would be able to use Request.Querystring("unitID"), and Request.Querystring("semester") from the 'details.asp' page.

so this is the code:
<td><a href="details.asp?selectedUnit=<%=rs("unitID")%>&selectedSemester=<%=rs("semester")%>"><%=rs("unitID")%></a></td><td><%=rs("unitname")%></td><td><%=rs("semester")%></td>

it creates a valid url, but when i click the link on the server, it throws an error. it does not happen when i remove '<%=rs("semester")%> from the url, so i cannot work out what is wrong here.

any feedback or pointers on my other code is welcome.

thanks in advance

rhys



'---------------------------- coordinator.asp

<!-- #include file="nocache.asp" -->
 

<%

if session("logInStatus") <> "y" then

	server.transfer("logoff.asp")

else

	set conn = server.createobject("ADODB.connection")

	conn.open "(hidden)", "(hidden)", "(hidden)"

	sql = "select * from UnitOffering "

	sql = sql & "where staffID = '" & session("userStaffID") & "'"

	sql = sql & "order by semester asc, unitID"

	set rs = conn.execute(sql)

end if

%>

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"

  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
 

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 

<head>

	<title>Coordinator</title>

	<link rel="stylesheet" type="text/css" href="Assign2.css" />

	

</head>
 

<body>

	<h1>Unit report for <%=session("userName")%></h1>

	<a id="logout" href="logoff.asp">Log Out</a>

	<h2>Units Coordinating</h2>

	<table border="1px">

		<tr>

			<th>Unit ID</th><th>Unit Name</th><th>Semester</th>

		</tr>

<%do while not rs.eof%>

		<tr>	

			<td><a href="details.asp?selectedUnit=<%=rs("unitID")%>&selectedSemester=<%=rs("semester")%>"><%=rs("unitID")%></a></td><td><%=rs("unitname")%></td><td><%=rs("semester")%></td>

		</tr>

<%rs.movenext

loop%>

	</table><br />

<%

set conn = server.createobject("ADODB.connection")

conn.open "(hidden)", "(hidden)", "(hidden)"

sql = "select Teaching.unitID, Teaching.semester, campus, unitname, Teaching.staffID, UnitOffering.staffID "

sql = sql & "from Teaching, UnitOffering "

sql = sql & "where Teaching.staffID = '" & session("userStaffID") & "'"

set rs = conn.execute(sql)

%>

	<h2>Units Teaching</h2>

	<table border="1px">

		<tr>

			<th>Unit ID</th><th>Unit Name</th><th>Semester</th><th>Campus</th><th>Coordinator's ID</th>

		</tr>

		<%do while not rs.eof%>

		<tr>

			<td><%=rs("unitID")%></td><td><%=rs("unitname")%></td><td><%=rs("semester")%></td><td><%=rs("campus")%></td><td><%=rs("staffID")%></td>

		</tr>

<%rs.movenext

loop%>

	</table><br />

</body>

</html>
 
 

'-------------------- details.asp -------------------------------
 

<!-- #include file="nocache.asp" -->
 

<%

if session("loginStatus") <> "y" then

	server.transfer("logoff.asp")

else

	selectedUnit = request.querystring("selectedUnit") 

	selectedSemester = request.querystring("selectedSemester")

	set conn = server.createobject("ADODB.connection")

	conn.open "(hidden)", "(hidden)", "(hidden)"

	sql = "select unitID, unitname, level, semester, name, campus, room, building, phone, email " 

	sql = sql & "from UnitOffering, Staff " 

	sql = sql & "where UnitOffering.staffID = Staff.staffID and semester = '"& selectedSemester & "' and unitID = '" & selectedUnit & "'"

	set rs = conn.execute(sql)

end if

%>                    
 

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"

  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
 

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 

<head>

	<title>Unit Details</title>

	<link rel="stylesheet" type="text/css" href="Assign2.css" />

	

</head>
 

<body>

	

	<a href="logoff.asp">Log Out</a>

	<h1>Unit Details</h1>

	<ul>

		<li>Unit ID: <%=rs("unitID") %></li>

		<li>Unit Name: <%=rs("unitname")%></li>

		<li>Level: <%=rs("level")%></li>

		<li>Semester: <%=rs("semester")%></li>

	</ul>

	<h2>Coordinator</h2>

	<h3><%=rs("name")%></h3>

	<ul>

		<li>Location

			<ul>

				<li>Campus: <%=rs("campus")%></li>

				<li>Building: <%=rs("building")%></li>

				<li>Room: <%=rs("room")%></li>

			</ul>

		</li>

		<li>Contact Details

			<ul>

				<li>Phone: <%=rs("phone")%></li>

				<li>Email: <%=rs("email")%></li>

			</ul>

		</li>

	</ul>

<%

selectedUnit = request.querystring("selectedUnit") 

set conn = server.createobject("ADODB.connection")

conn.open "(hidden)", "(hidden)", "(hidden)"

sql = "select distinct unitID, Staff.campus, name, room, building, phone, email "

sql = sql & " from Teaching, Staff "

sql = sql & " where Teaching.staffID = Staff.staffID and unitID = '" & selectedUnit & "'"

set rs = conn.execute(sql)

%>

	

	<h2>Lecturers</h2>

<%do while not rs.eof%>

	<h3><%=rs("name")%></h3>

	<ul>

		<li>Location

			<ul>

				<li>Campus: <%=rs("campus")%></li>

				<li>Building: <%=rs("building")%></li>

				<li>Room: <%=rs("room")%></li>

			</ul>

		</li>

		<li>Contact Details

			<ul>

				<li>Phone: <%=rs("phone")%></li>

				<li>Email: <%=rs("email")%></li>

			</ul>

		</li>

	</ul>

<%rs.movenext

loop%>

	<Table>

<%

selectedUnit = request.querystring("selectedUnit")

set conn = server.createobject("ADODB.connection")

conn.open "(hidden)", (hidden)", (hidden)"

sql = "select assessmentName, weight, dueDate, dueTime"

sql = sql & " from Assessment"

sql = sql & " where Assessment.unitID = '"& selectedUnit & "'"

set rs = conn.execute(sql) 

%>

		<form id="aTask" method="post" action="validate.asp" >

			<tr>

				<th>Assessment Name</th><th>Weight</th><th>Due Date</th><th>Due Time</th>

			</tr>

<%do while not rs.eof%>

			<tr>

				<td><input type="text" name="assessName" value="<%=rs("assessmentName")%>" /></td>

				<td><input type="text" name="weight" value="<%=rs("weight")%>" /></td>

				<td><input type="text" name="dueDate" value="<%=rs("dueDate")%>" /></td>

				<td><input type="text" name="dueTime" value="<%=rs("dueTime")%>" /></td>

			</tr>

<%

loop%>

		</form>

	</table>

</body>

</html>

Open in new window

0
Comment
Question by:rhysbwaller
  • 3
4 Comments
 
LVL 82

Accepted Solution

by:
hielo earned 500 total points
Comment Utility
you forgot to advance the recorset pointer
...

<%do while not rs.eof%>

                        <tr>

                                <td><input type="text" name="assessName" value="<%=rs("assessmentName")%>" /></td>

                                <td><input type="text" name="weight" value="<%=rs("weight")%>" /></td>

                                <td><input type="text" name="dueDate" value="<%=rs("dueDate")%>" /></td>

                                <td><input type="text" name="dueTime" value="<%=rs("dueTime")%>" /></td>

                        </tr>

<%

loop%>

...
 

befor loop you need:

rs.moveNext
 
 
 

...

<%do while not rs.eof%>

                        <tr>

                                <td><input type="text" name="assessName" value="<%=rs("assessmentName")%>" /></td>

                                <td><input type="text" name="weight" value="<%=rs("weight")%>" /></td>

                                <td><input type="text" name="dueDate" value="<%=rs("dueDate")%>" /></td>

                                <td><input type="text" name="dueTime" value="<%=rs("dueTime")%>" /></td>

                        </tr>

<%

rs.moveNext

loop

%>

Open in new window

0
 
LVL 82

Expert Comment

by:hielo
Comment Utility

---------------------------- coordinator.asp

<!-- #include file="nocache.asp" -->

 

<%

if session("logInStatus") <> "y" then

        server.transfer("logoff.asp")

else

        set conn = server.createobject("ADODB.connection")

        conn.open "(hidden)", "(hidden)", "(hidden)"

        sql = "select * from UnitOffering "

        sql = sql & "where staffID = '" & session("userStaffID") & "'"

        sql = sql & "order by semester asc, unitID"

        set rs = conn.execute(sql)

end if

%>

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"

  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 

 

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

 

<head>

        <title>Coordinator</title>

        <link rel="stylesheet" type="text/css" href="Assign2.css" />

        

</head>

 

<body>

        <h1>Unit report for <%=session("userName")%></h1>

        <a id="logout" href="logoff.asp">Log Out</a>

        <h2>Units Coordinating</h2>

        <table border="1px">

                <tr>

                        <th>Unit ID</th><th>Unit Name</th><th>Semester</th>

                </tr>

<%do while not rs.eof%>

                <tr>    

                        <td><a href='details.asp?selectedUnit=<%=rs.Fields("unitID").value%>&selectedSemester=<%=Server.URLEncode(rs.Fields("semester").value)%>'><%=rs("unitID")%></a></td><td><%=rs("unitname")%></td><td><%=rs("semester")%></td>

                </tr>

<%

rs.movenext

loop%>

        </table><br />

<%

set conn = server.createobject("ADODB.connection")

conn.open "(hidden)", "(hidden)", "(hidden)"

sql = "select Teaching.unitID, Teaching.semester, campus, unitname, Teaching.staffID, UnitOffering.staffID "

sql = sql & "from Teaching, UnitOffering "

sql = sql & "where Teaching.staffID = '" & session("userStaffID") & "'"

set rs = conn.execute(sql)

%>

        <h2>Units Teaching</h2>

        <table border="1px">

                <tr>

                        <th>Unit ID</th><th>Unit Name</th><th>Semester</th><th>Campus</th><th>Coordinator's ID</th>

                </tr>

                <%do while not rs.eof%>

                <tr>

                        <td><%=rs("unitID")%></td><td><%=rs("unitname")%></td><td><%=rs("semester")%></td><td><%=rs("campus")%></td><td><%=rs("staffID")%></td>

                </tr>

<%

rs.movenext

loop%>

        </table><br />

</body>

</html>

 

 

'-------------------- details.asp -------------------------------

 

<!-- #include file="nocache.asp" -->

 

<%

if session("loginStatus") <> "y" then

        server.transfer("logoff.asp")

else

        selectedUnit = request.querystring("selectedUnit") 

        selectedSemester = request.querystring("selectedSemester")

        set conn = server.createobject("ADODB.connection")

        conn.open "(hidden)", "(hidden)", "(hidden)"

        sql = "select unitID, unitname, level, semester, name, campus, room, building, phone, email " 

        sql = sql & "from UnitOffering, Staff " 

        sql = sql & "where UnitOffering.staffID = Staff.staffID and semester = '"& selectedSemester & "' and unitID = '" & selectedUnit & "'"

        set rs = conn.execute(sql)

end if

%>                    

 

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"

  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 

 

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

 

<head>

        <title>Unit Details</title>

        <link rel="stylesheet" type="text/css" href="Assign2.css" />

        

</head>

 

<body>

        

        <a href="logoff.asp">Log Out</a>

        <h1>Unit Details</h1>

        <ul>

                <li>Unit ID: <%=rs("unitID") %></li>

                <li>Unit Name: <%=rs("unitname")%></li>

                <li>Level: <%=rs("level")%></li>

                <li>Semester: <%=rs("semester")%></li>

        </ul>

        <h2>Coordinator</h2>

        <h3><%=rs("name")%></h3>

        <ul>

                <li>Location

                        <ul>

                                <li>Campus: <%=rs("campus")%></li>

                                <li>Building: <%=rs("building")%></li>

                                <li>Room: <%=rs("room")%></li>

                        </ul>

                </li>

                <li>Contact Details

                        <ul>

                                <li>Phone: <%=rs("phone")%></li>

                                <li>Email: <%=rs("email")%></li>

                        </ul>

                </li>

        </ul>

<%

selectedUnit = request.querystring("selectedUnit") 

set conn = server.createobject("ADODB.connection")

conn.open "(hidden)", "(hidden)", "(hidden)"

sql = "select distinct unitID, Staff.campus, name, room, building, phone, email "

sql = sql & " from Teaching, Staff "

sql = sql & " where Teaching.staffID = Staff.staffID and unitID = '" & selectedUnit & "'"

set rs = conn.execute(sql)

%>

        

        <h2>Lecturers</h2>

<%do while not rs.eof%>

        <h3><%=rs("name")%></h3>

        <ul>

                <li>Location

                        <ul>

                                <li>Campus: <%=rs("campus")%></li>

                                <li>Building: <%=rs("building")%></li>

                                <li>Room: <%=rs("room")%></li>

                        </ul>

                </li>

                <li>Contact Details

                        <ul>

                                <li>Phone: <%=rs("phone")%></li>

                                <li>Email: <%=rs("email")%></li>

                        </ul>

                </li>

        </ul>

<%

rs.movenext

loop

%>

        <Table>

<%

selectedUnit = request.querystring("selectedUnit")

set conn = server.createobject("ADODB.connection")

conn.open "(hidden)", (hidden)", (hidden)"

sql = "select assessmentName, weight, dueDate, dueTime"

sql = sql & " from Assessment"

sql = sql & " where Assessment.unitID = '"& selectedUnit & "'"

set rs = conn.execute(sql) 

%>

                <form id="aTask" method="post" action="validate.asp" >

                        <tr>

                                <th>Assessment Name</th><th>Weight</th><th>Due Date</th><th>Due Time</th>

                        </tr>

<%

do while not rs.eof

%>

                        <tr>

                                <td><input type="text" name="assessName" value="<%=rs("assessmentName")%>" /></td>

                                <td><input type="text" name="weight" value="<%=rs("weight")%>" /></td>

                                <td><input type="text" name="dueDate" value="<%=rs("dueDate")%>" /></td>

                                <td><input type="text" name="dueTime" value="<%=rs("dueTime")%>" /></td>

                        </tr>

<%

rs.moveNext

loop

%>

                </form>

        </table>

</body>

</html>

Open in new window

0
 

Author Closing Comment

by:rhysbwaller
Comment Utility
Thankyou very much. good eyes!
0
 
LVL 82

Expert Comment

by:hielo
Comment Utility
you are welcome.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

743 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

15 Experts available now in Live!

Get 1:1 Help Now