Update Multiple Records with One submit

Discussion in 'ASP General' started by Olivia Towery, Aug 14, 2003.

  1. SQL 6.5 Database

    I have a list of registrants and I want to use a check box after each record
    to show those who attend and then post all with one submit button.

    Any help is appreciated.

    --
    Olivia Towery
    Tower Internet Management
    Olivia Towery, Aug 14, 2003
    #1
    1. Advertising

  2. Olivia Towery

    Tom B Guest

    You can loop through your results, and send an update for each one. Do you
    need to update those who don't attend?

    I'll assume you don't have to update those who don't.

    So on your form you'd have.....

    Joe Blow <input type=checkbox name=ATTENDED value=1>
    Fred Smith <input type=checkbox name=ATTENDED value=8>
    Jen Jones <input type=checkbox name=ATTENDED value=3>
    Gerald Springer<input type=checkbox name=ATTENDED value=99>

    (Note that the value is the registrants ID from the database)

    When the page is submitted the value of Request.Form("ATTENDED") will be a
    comma delimited string of the selected values, so assuming just Joe, Jen and
    Gerald are checked then it would equal "1,8,99" So, split it into an array
    and update the database


    Dim arrRegistrants
    Dim iLoop
    Dim sSQL
    arrRegistrants=Split(Request.Form("ATTENDED"),",")

    for iLoop=0 to Ubound(arrRegistrants)
    sSQL="UPDATE tblWhatever Set Attended=1 WHERE RegistrantID=" &
    arrRegistrants(iLoop)
    CN.Execute sSQL 'Assuming CN is a valid and open connection object
    next


    You could also send a single sql statement along the lines of

    sSQL="UPDATE tblWhatever SET Attended=1 WHERE RegistrantID IN (" &
    Request.Form("ATTENDED") & ")"

    which would look like this
    UPDATE tblWhatever SET Attended=1 WHERE RegistrantID IN (1,8,99)

    I think that's right, check BOL.




    "Olivia Towery" <> wrote in message
    news:...
    > SQL 6.5 Database
    >
    > I have a list of registrants and I want to use a check box after each

    record
    > to show those who attend and then post all with one submit button.
    >
    > Any help is appreciated.
    >
    > --
    > Olivia Towery
    > Tower Internet Management
    >
    >
    Tom B, Aug 14, 2003
    #2
    1. Advertising

  3. Thanks Tom. But what if I do want to be able to uncheck a box and have the
    db updated? Can this be done?

    "Tom B" <> wrote in message
    news:...
    > You can loop through your results, and send an update for each one. Do

    you
    > need to update those who don't attend?
    >
    > I'll assume you don't have to update those who don't.
    >
    > So on your form you'd have.....
    >
    > Joe Blow <input type=checkbox name=ATTENDED value=1>
    > Fred Smith <input type=checkbox name=ATTENDED value=8>
    > Jen Jones <input type=checkbox name=ATTENDED value=3>
    > Gerald Springer<input type=checkbox name=ATTENDED value=99>
    >
    > (Note that the value is the registrants ID from the database)
    >
    > When the page is submitted the value of Request.Form("ATTENDED") will be a
    > comma delimited string of the selected values, so assuming just Joe, Jen

    and
    > Gerald are checked then it would equal "1,8,99" So, split it into an array
    > and update the database
    >
    >
    > Dim arrRegistrants
    > Dim iLoop
    > Dim sSQL
    > arrRegistrants=Split(Request.Form("ATTENDED"),",")
    >
    > for iLoop=0 to Ubound(arrRegistrants)
    > sSQL="UPDATE tblWhatever Set Attended=1 WHERE RegistrantID=" &
    > arrRegistrants(iLoop)
    > CN.Execute sSQL 'Assuming CN is a valid and open connection object
    > next
    >
    >
    > You could also send a single sql statement along the lines of
    >
    > sSQL="UPDATE tblWhatever SET Attended=1 WHERE RegistrantID IN (" &
    > Request.Form("ATTENDED") & ")"
    >
    > which would look like this
    > UPDATE tblWhatever SET Attended=1 WHERE RegistrantID IN (1,8,99)
    >
    > I think that's right, check BOL.
    >
    >
    >
    >
    > "Olivia Towery" <> wrote in message
    > news:...
    > > SQL 6.5 Database
    > >
    > > I have a list of registrants and I want to use a check box after each

    > record
    > > to show those who attend and then post all with one submit button.
    > >
    > > Any help is appreciated.
    > >
    > > --
    > > Olivia Towery
    > > Tower Internet Management
    > >
    > >

    >
    >
    Olivia Towery, Aug 14, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Edward
    Replies:
    1
    Views:
    307
    =?Utf-8?B?UmF2aW5kcmE=?=
    Jun 10, 2004
  2. Geoff Winsor
    Replies:
    3
    Views:
    6,687
    Ryan Stewart
    Jan 29, 2005
  3. Dan

    Delete records or update records

    Dan, May 10, 2004, in forum: ASP General
    Replies:
    1
    Views:
    452
    Ray at
    May 10, 2004
  4. Sans Spam
    Replies:
    8
    Views:
    234
    Sans Spam
    May 24, 2004
  5. Drew
    Replies:
    7
    Views:
    191
    Ray Costanzo [MVP]
    Nov 10, 2004
Loading...

Share This Page