Roster_view.asp

Page source

<html> <head> <style type="text/css"> <!-- body { font-family: Verdana } --> </style> <title>Display the roster</title> </head> <body bgcolor="#ffffff"> <h2>CIS 471 roster</h2> <table border="1" cellpadding="5" cellspacing =" 0"> <thead> <tr> <td><b>Name</b></td> <td><b>Email address</b></td> <td><b>URL on SWS server</b></td> <td><b>Action</b></td> </tr> </thead> <tr> <td>Jones, John</td> <td><a href="mailto:jjones@any.net">jjones@any.net</a></td> <td><a href="http://sws.csudh.edu/jjones/">sws.csudh.edu/jjones/</a></td> <td align="center"><a href="student_del_confirm.asp?RecID=47">Delete</a></td> </tr> <tr> <td>Smith, Bob</td> <td><a href="mailto:bsmith@any.com">bsmith@any.com</a></td> <td><a href="http://sws.csudh.edu/bsmith/">sws.csudh.edu/bsmith/</a></td> <td align="center"><a href="student_del_confirm.asp?RecID=38">Delete</a> </td> </tr> </table> <p> <FORM ACTION="new_student.asp" METHOD="post"><p> <INPUT TYPE="submit" VALUE="Add a new student"></INPUT></FORM> </body> </html>

Script listing

<html> <head> <style type="text/css"> <!-- body { font-family: Verdana } --> </style> <title>Display the roster</title> </head> <body bgcolor="#ffffff"> <h2>CIS 471 roster</h2> <% ' This script displays the student roster from the database ' Create and establish data connection called "DataConn" Dim DataConn Set DataConn = Server.CreateObject("ADODB.Connection") DataConn.Mode = 3 '3 = adModeReadWrite DataConn.ConnectionTimeout = 5 DataConn.CommandTimeout = 12 DataConn.Open Session.Value("DBOpen") ' Create and load the a record set called "rsRoster" Dim cmdText, rsRoster cmdText = "SELECT * FROM Roster_CIS ORDER BY LastName ASC" Set rsRoster = Server.CreateObject("ADODB.Recordset") 'create the record set object rsRoster.Open cmdText, DataConn, 0, 1, 1 '0,1,1 indicates forward-cursor, read-only mode ' Display HTML Table containing each row from the Roster database table ' Write column headers Response.Write("<table border=""1"" cellpadding=""5"" cellspacing = ""0"">") Response.Write("<thead> <tr>") Response.Write("<td><b>Name</b></td>") Response.Write("<td><b>Email address</b></td>") Response.Write("<td><b>URL on SWS server</b></td>") Response.Write("<td><b>Action</b></td>") Response.Write("</tr>") Response.Write("</thead>") ' Loop through recordset and display results Dim strTemp Do While Not rsRoster.EOF Response.Write("<tr>") strTemp = rsRoster.Fields("LastName") & ", " & rsRoster.Fields("FirstName") Response.Write("<td>") Response.Write(strTemp) Response.Write("</td>") 'email address strTemp = "<a href=""" & "mailto:" & rsRoster.Fields("Email") & """>" & rsRoster.Fields("Email") & "</a>" Response.Write("<td>") Response.Write(strTemp) Response.Write("</td>") 'URL on sws strTemp = "<a href=""" & "http://" & rsRoster.Fields("URL") & """>" & rsRoster.Fields("URL") & "</a>" Response.Write("<td>") Response.Write(strTemp) Response.Write("</td>") 'URL for Delete with RecID set appropriately strTemp = "<a href=""student_del_confirm.asp?RecID=" & CStr(rsRoster.Fields("RecID")) & """>Delete</a>" Response.Write("<td align=""center"">") Response.Write(strTemp) Response.Write("</td>") 'Finish the table row Response.Write("</tr>") rsRoster.MoveNext Loop Response.Write("</table> <p>") ' Put a form with the "new student" button at the bottom of the page. response.write ("<FORM ACTION=""new_student.asp"" METHOD=""post""><p>") response.write ("<INPUT TYPE=""submit"" VALUE=""Add a new student""></INPUT></FORM>") ' return connection and dataset memory rsRoster.Close Set rsRoster = Nothing DataConn.Close Set DataConn = Nothing %> </body> </html>

Disclaimer: The views and opinions expressed on unofficial pages of California State University, Dominguez Hills faculty, staff or students are strictly those of the page authors. The content of these pages has not been reviewed or approved by California State University, Dominguez Hills.