Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
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
Medium Priority
?
225 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 2000 total points
ID: 22760044
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
ID: 22760055

---------------------------- 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
ID: 31507891
Thankyou very much. good eyes!
0
 
LVL 82

Expert Comment

by:hielo
ID: 22760239
you are welcome.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Backups and Disaster RecoveryIn this post, we’ll look at strategies for backups and disaster recovery.
Microsoft Jet database engine errors can crop up out of nowhere to disrupt the working of the Exchange server. Decoding why a particular error occurs goes a long way in determining the right solution for it.
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

580 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