August 27th, 2013, 09:37 AM
-
How do I update all records that I check at once
Hello,
I like to add a checkbox next to the results record (Approve). When I check on each box, and update them at once. currently, I am able to update one record at the time.
How do I update all records that I check at once?
My code is below. Can you look at it and tell me what I need to change to make it work?
Thanks.
asp Code:
<%
Case "AdjudicateLeft"
Set rsLeftReq = Server.CreateObject("ADODB.Recordset")
strSQL = " SELECT tbl_Student.Name, tbl_Dept.Class_ID, tbl_Dept.Dept_ID, tbl_Dept.StartDate, tbl_Dept.EndDate, tbl_Dept.LeftStatus, tbl_Dept.LeftStatusID"
strSQL = strSQL & " FROM tbl_Dept INNER JOIN tbl_Student ON tbl_Dept.Student_ID = tbl_Student.Student_ID"
strSQL = strSQL & " WHERE tbl_Dept.Dept_ID=" & Request.QueryString("ID") & ""
rsLeftReq.CursorType = 2
rsLeftReq.LockType = 3
rsLeftReq.Open strSQL, adoCon
If Request.QueryString("Request")="Approve" Then
rsLeftReq.Fields("LeftStatus")="Approved"
rsLeftReq.Fields("LeftStatusDate")=Date()
rsLeftReq.Fields("LeftStatusID")=strLogon_User
rsLeftReq.Update
End If
Response.Redirect "page.asp?View=Left"
Set strAction=nothing
Set rsLeftReq=nothing
...
'RUN QUERY ------------------------------------------------------
Set rsResults = Server.CreateObject("ADODB.Recordset")
strSQL = " SELECT tbl_Student.Name, tbl_Dept.Class_ID, tbl_Dept.Dept_ID, tbl_Dept.StartDate, tbl_Dept.EndDate, tbl_Dept.LeftStatus, tbl_Dept.LeftStatusID"
strSQL = strSQL & " FROM tbl_Dept INNER JOIN tbl_Student ON tbl_Dept.Student_ID = tbl_Student.Student_ID"
strSQL = strSQL & " WHERE (tbl_Dept.Class_ID=5)"
strSQL = strSQL & " AND " & strGroupSQL & ""
strSQL = strSQL & " ORDER BY tbl_Dept.StartDate"
rsResults.Open strSQL, strCon, 3
Response.Write "<table>"
Response.Write " <tr>"
Response.Write " <td>"
Response.Write " <table>"
Response.Write " <tr>"
Response.Write " <td> </td>"
Response.Write " <td><A href=""Page.asp?Action=AdjudicateLeft&Request=Approve&ID=" & rsResults("Dept_ID") & """ onClick=""return confirm('Approve this one?');"">Approved Selected</a></td>"
Response.Write " <td><P><b>Status</b></td>"
Response.Write " <td><P><b>Name</b></td>"
Response.Write " <td><P><b>Left Type</b></td>"
Response.Write " <td><P><b>Start Date</b></td>"
Response.Write " <td><P><b>End Date</b></td>"
Response.Write " </tr>"
If CLng(rsResults.RecordCount)>0 Then
For i=1 to CLng(rsResults.RecordCount)
Response.Write " <tr>"
Response.Write " <td><A href=""Page.asp?Action=AdjudicateLeft&Request=Approve&ID=" & rsResults("Dept_ID") & """ onClick=""return confirm('Approve this one?');""><img src=""images/icon.gif"""></a></td>"
If IsNull(rsResults("LeftStatus")) Then
Response.Write " <td><P>Not approved</td>"
Else
If rsResults("LeftStatus")="Approved" Then
Response.Write " <td><P>" & rsResults("LeftStatus") & "</td>"
End If
End If
Response.Write " <td><P class=BodyText>" & rshResults("Name") & "</td>"
Response.Write " <td><P><input type=""checkbox"" value=""""></td>"
Response.Write " <td><P>" & rsResults("StartDate") & "</td>"
Response.Write " <td><P>" & rsResults("EndDate") & "</td>"
Response.Write " </tr>"
rsResults.MoveNext
Next
Else
Response.Write " <tr>"
Response.Write " <td><P> No Records Found</td>"
Response.Write " </tr>"
End If
Response.Write " </table>"
Response.Write " </td>"
Response.Write " </tr>"
Response.Write "</table>"
%>
Last edited by requinix; August 27th, 2013 at 12:40 PM.
Reason: php->highlight tags
August 27th, 2013, 09:50 PM
-
Unless you can come up with an SQL Where that will identify just the records to be updated, it's easiest and safest to just do one at a time.
======
Doug G
======
I've never been able to appreciate the sublime arrogance of folks who feel they were put on earth just to save other folks from themselves .." - Donald Hamilton
August 28th, 2013, 11:16 AM
-
I alredy posted solution on that on asp free forum look there
August 28th, 2013, 11:50 AM
-
Where is it?
Can you provide a link?
Thanks.
August 28th, 2013, 12:40 PM
-
Originally Posted by jennypretty
Where is it?
Can you provide a link?
Thanks.
http://forums.aspfree.com/asp-development-5/how-do-i-update-all-records-i-check-once-538856.html