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
216 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
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
These days, all we hear about hacktivists took down so and so websites and retrieved thousands of user’s data. One of the techniques to get unauthorized access to database is by performing SQL injection. This article is quite lengthy which gives bas…
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

791 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