HELP!!! Update mutiple records

Results 1 to 3 of 3

Thread: HELP!!! Update mutiple records

  1. #1
    Alex T. Guest

    Default HELP!!! Update mutiple records

    Hi...I got this code from somewhere and it&#039s orginial purpose was to delete mutiple records in a list by checking the checkbox next to it and then clicking the delete button. I got it to work fine when I was deleting mutiple records. Now I am trying to change the value of a field in the database for mutiple records. If I just check one record, it works fine, however if I check more than one it gives me an error. Any ideas?<BR><BR>Set MyConn=Server.CreateObject("ADODB.Connection")<BR> MyConn.Open "MyDSN", "UID", "Password"<BR><BR><BR>SQL = "UPDATE tblUsers SET AccountStatus=&#039 2&#039 WHERE UserID=("&request.form("toActivate")&")"<BR>&#039g rab the value(s) selected from the checkboxes<BR>SQL2 = "UPDATE tblUsers SET AccountStatus=&#039 2&#039 WHERE UserID=("&request.form("toActivate")&")"<BR><BR>Se t RS = MyConn.Execute(SQL)<BR>Set RS = MyConn.Execute(SQL2)<BR><BR>MyConn.Close<BR>Set MyConn = Nothing<BR><BR>P.S. Bsaically I just want to change the value of the AccountStatus field in mutiple records from 1 to 2. Thanks in advance!

  2. #2
    Join Date
    Dec 1969

    Default RE: HELP!!! Update mutiple records

    U cannot assign two queries to the same Rs one after the other.the other thing is u really don&#039t need a recordset when u want to update just say<BR><BR>Conn.Execute(SQL1)<BR>Conn.Execute(SQL2 )with appropriate query/queries

  3. #3
    Alex T. Guest

    Default RE: HELP!!! Update mutiple records

    Okay, I now have this code, but still with the same results:<BR><BR>Dim SQL, Conn<BR>Set Conn = Server.CreateObject("ADODB.Connection")<BR>Conn.Op en "myDSN", "UID", "Password"<BR>SQL = "UPDATE tblUsers SET AccountStatus=&#039 2&#039 WHERE UserID=("&request.form("toActivate")&")"<BR>Conn.E xecute SQL<BR>Conn.Close<BR>Set Conn = Nothing<BR><BR><BR>Again, it works fine with just one record, but not multiple records.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts