Right. It seems to me page1 is OK, except for one thing. Page two will display the record when you pass
select as the action, so you need to change the following in your Recordset loop:
Code:
strOutPutString = strOutPutString & "<TR>" & _
"<TD valign=top><a href=""Display2.asp?ID=" & objRS("ID") & "
&action=select""><img src=images/" & objRS("solved")
& ".gif></a>" & _
This way, you'll pass action=select to page2, where it can be used to retrieve the record.
Page 2 should look like below. Notice that I changed all the refs to
objRs(FieldName) to
StringFieldName. Since you stuffed the values from the recordset in the variable, and then closed the recordset, you shouldn't refer to the recordset anymore, but use the variable instead. I highlighted a few to show you what I mean.
<shameless plug>
You could consider getting a copy of Beginning Dreamweaver MX. Besides introducing Dreamweaver, we also discuss all these kind of issues. Retrieving, inserting, updating data from database, displaying them on ASP pages, protecting your web site using a login-mechanism etc.
</shameless plug>
Hope this helps. Step by step, remember.... ;)
Imar
[code]page 2 Display2.asp
<%
Option Explicit
Dim strStatus
%>
<%
Dim Connection
Dim connStatus
Dim objRS
Dim strSQL
Dim intID
Dim sFName, sLName, sEmail, sPhone, sRepeat, sPriority, sComment, sTech, sNotes, sDept, sDate, sTime, sSolved
Dim SCRIPT_NAME
SCRIPT_NAME = Request.ServerVariables("SCRIPT_NAME")
Set Connection = Server.CreateObject("ADODB.Connection")
Select Case LCase(Trim(Request.QueryString("action")))
Case "editsave"
' Updating, so take ID from Form
intID = Request.Form("ID")
intID = Replace(intID, "'", "''")
If Len(intID) > 0 Then
' You shouldn't just use this check for creating
' the SQL statement, but for the entire update as well
' If intID is a zero length string, there is no
' point in executing the query
' Move all actions that consume time to before the .Open statement
' An open connection is a scarce resource, so use it as
' briefly as possible
' You can't use the comma in your SQL statement
' as you are updating just one field
' I changed it to space, so it doesn't conflict with the WHERE clause
' I also changed Request.Form("Name") to Request.Form("Fname")
strSQL = "UPDATE tblIThelp SET " _
& "Fname = '" & (Request.Form("Fname")) & "' " _
& "Lname = '" & (Request.Form("Lname")) & "' " _
& "Email = '" & (Request.Form("email")) & "' " _
& "phone = '" & (Request.Form("phone")) & "' " _
& "dept = '" & (Request.Form("dept")) & "' " _
& "repeat = '" & (Request.Form("repeat")) & "' " _
& "priority = '" & (Request.Form("priority")) & "' " _
& "Comment = '" & (Request.Form("comment")) & "' " _
& "notes = '" & (Request.Form("notes")) & "' " _
& "tech = '" & (Request.Form("tech")) & "' " _
& "date = '" & (Request.Form("date")) & "' " _
& "time = '" & (Request.Form("time")) & "' " _
& "solved = '" & (Request.Form("solved")) & "' " _
& "WHERE (id = " & intID & ")"
' Use Response.Write(strStatus) to output the SQL to the
' browser for debugging purposes. Comment the next two lines
' again when the SQL looks OK.
Response.Write(strStatus)
Response.End()
Connection.Open strStatus
Connection.Execute(strSQL)
Connection.Close()
Set Connection = Nothing
Response.Redirect("ViewIThelp.asp")
' If the update is successful, redirect away
End If
Case "select"
' Selecting, so take ID from querystring
intID = Request.QueryString("ID")
If Len(intID) > 0 Then
strSQL = "SELECT * FROM [tblIThelp] WHERE [ID] =" & intID
Connection.Open strStatus
Set objRS = Connection.Execute(strSQL)
' By using a variable, you don't run the risk of having
' an error in the form when objRS is EOF
sFName = objRS("Fname")
sLName = objRS("Fname")
sEmail = objRS("Fname")
sPhone = objRS("Fname")
sPriority = objRS("Fname")
sRepeat = objRS("Fname")
sComment = objRS("Fname")
sTech = objRS("Fname")
sNotes = objRS("Fname")
sDept = objRS("Fname")
sDate = objRS("Fname")
sTime = objRS("Fname")
sSolved = objRS("Fname")
Connection.Close
Set Connection = Nothing
End If
Case else
Response.Write("Sorry, but you are supposed to pass a valid querystring" & _
" to this page.")
End Select
%>
<html>
<body>
<form name="form1" method="post" action="<%=Request.ServerVariables("SCRIPT_NAME")% >?action=editsave">
<input type="text" name="Fname" value=
<%=sFname%>>
<input type="text" name="Lname" value=
<%=sLname%>>
<img src="images/
<%=sSolved%>.gif">
<input type="text" name="email"value=<%=sEmail%>>
<input type="text" name="phone" value=<%=sPhone%>>
<input type="text" name="Dept" value=<%=sDept%>>
<select name="repeat">
<option value="yes">Yes</option>
<option value="no">No</option>
<option selected><%=sRepeat%></option>
</select>
<select name="priority">
<option value="high">Yes</option>
<option value="low">No</option>
<option selected><%=sPriority%></option>
</select>
<textarea name="comment" cols="54"><%=sComment%></textarea>
<input type="text" name="tech" value=<%=sTech%>>
<input type="text" name="date" value=<%=sDate%>>
<input type="text" name="time" value=<%=sTime%>>
<textarea name="notes" cols="54"><%=sNotes%></textarea>
<input type="submit" name="Submit" value="Submit">
</form>
</body>
</html>