#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2008
    Posts
    27
    Rep Power
    0

    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>&nbsp;</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>&nbsp;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
  2. #2
  3. No Profile Picture
    Grumpier old Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jun 2003
    Posts
    14,424
    Rep Power
    4539
    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
    ======
    The man who doesn't read good books has no advantage over the man who can't read them.
    --Mark Twain
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    103
    Rep Power
    9
    I alredy posted solution on that on asp free forum look there
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2008
    Posts
    27
    Rep Power
    0
    Where is it?
    Can you provide a link?

    Thanks.
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    103
    Rep Power
    9
    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

IMN logo majestic logo threadwatch logo seochat tools logo