update multiple rows

Discussion in 'ASP General' started by shank, Aug 28, 2004.

  1. shank

    shank Guest

    Visually, the page will look somewhat like a spreadsheet. It could have
    hundreds of records (rows) displayed. I want to enable the user to edit any
    one or any number of records and any fields, then click a save button to
    UPDATE the SQL table. I'd like to use stored procedures if possible. How is
    this done? Where do I start?

    thanks
     
    shank, Aug 28, 2004
    #1
    1. Advertising

  2. shank

    Scott Guest

    Scott, Aug 29, 2004
    #2
    1. Advertising

  3. shank

    shank Guest

    shank, Aug 29, 2004
    #3
  4. shank

    Harag Guest

    On Sat, 28 Aug 2004 16:52:36 -0400, "shank" <>
    wrote:

    >Visually, the page will look somewhat like a spreadsheet. It could have
    >hundreds of records (rows) displayed. I want to enable the user to edit any
    >one or any number of records and any fields, then click a save button to
    >UPDATE the SQL table. I'd like to use stored procedures if possible. How is
    >this done? Where do I start?
    >
    >thanks
    >


    Firstly you need to think about the front end a bit more and who are
    the users that will be using it imho (lan, intranet, just you, couple
    admin people or the millions on the web?)

    Look at not displaying 100's of rows but only 10-30 or so at a time
    for this you would need some sort of paging stored proc.

    http://www.aspfaq.com/2120

    check out the last version listed using @@rowcount by Chris Hohmann
    for this.


    Also saving the info... will it be one save button at the bottom? or
    one for each row ?

    eg

    <form ...>
    line 1 ID: <input type="hidden" name="memID" value="1234">
    line 1 name: <input type="text" name="memName" value="fred
    flintstone">
    line 1 age: <input type="text" name="memAge" value="32">

    line 2 ID: <input type="hidden" name="memID" value="1235">
    line 2 name: <input type="text" name="memName" value="Wilma
    flintstone">
    line 2 age: <input type="text" name="memAge" value="28">

    line 3 ID: <input type="hidden" name="memID" value="1236">
    line 3 name: <input type="text" name="memName" value="dino
    flintstone">
    line 3 age: <input type="text" name="memAge" value="4">

    <input type="submit" value="save all">
    </form>

    by doing the above all the above info will be sent to the server in 3
    "arrays"

    response.form("memID") would be "1234, 1235, 1236"
    response.form("memName") "fred flintstone, wilma flintstone, dino ..."
    response.form("memAge") "32, 28, 4"

    which you can then send to the DB stored proc and get that to update
    the info. Since SQL servers dont have arrays as such then you would
    need to check out the following page:

    http://www.sommarskog.se/arrays-in-sql.html



    If you have a save button for each entry.

    <form ...>
    line 1 ID: <input type="hidden" name="memID" value="1234">
    line 1 name: <input type="text" name="memName" value="fred
    flintstone">
    line 1 age: <input type="text" name="memAge" value="32">
    <input type="submit" value="save">
    </form>
    <form ...>
    line 2 ID: <input type="hidden" name="memID" value="1235">
    line 2 name: <input type="text" name="memName" value="Wilma
    flintstone">
    line 2 age: <input type="text" name="memAge" value="28">
    <input type="submit" value="save">
    </form>
    <form ...>
    line 3 ID: <input type="hidden" name="memID" value="1236">
    line 3 name: <input type="text" name="memName" value="dino
    flintstone">
    line 3 age: <input type="text" name="memAge" value="4">
    <input type="submit" value="save">
    </form>


    Then the user will have to click it for each line he has changed. and
    one line of info will be sent to the DB and updated, accordingly.


    Next - the result... where to send the "save" result. well. since it
    has to go to the server to send the info and to update the db, how are
    you going to tell the user this has worked ok. Personally when I do
    forms I (near) always put the DB updating code in the same for as the
    displaying code. so the code for the above would look like this:


    FILENAME.ASP.


    1) check to see if a form has been posted to this file.
    2) if not 1 skil step 3
    3a) if 1 then run function "updateDB()" or whatever.
    3b) if 2 ok tell user "info saved" or store in variable for later
    display

    4) get page data(ie the 20 rows to display)
    5) display page info to user.
    6) EOF.



    Other things to think about on the frontend, is what javascript you
    might want to make it easier for the user. eg. how about disabling the
    save button and only enable it when the user actually changes some
    text? or if your doing a SaveALL then you could have another hidden
    entry like the MemID which is just 1 or a 0 and set it to 1 when the
    user has changed any info, then in the DB stored proc you only need to
    update the rows where this value is a 1.


    good luck.

    HTH.

    Al
     
    Harag, Aug 29, 2004
    #4
  5. shank

    shank Guest

    "Harag" <> wrote in message
    news:...
    > On Sat, 28 Aug 2004 16:52:36 -0400, "shank" <>
    > wrote:
    >
    > >Visually, the page will look somewhat like a spreadsheet. It could have
    > >hundreds of records (rows) displayed. I want to enable the user to edit

    any
    > >one or any number of records and any fields, then click a save button to
    > >UPDATE the SQL table. I'd like to use stored procedures if possible. How

    is
    > >this done? Where do I start?
    > >
    > >thanks
    > >

    >
    > Firstly you need to think about the front end a bit more and who are
    > the users that will be using it imho (lan, intranet, just you, couple
    > admin people or the millions on the web?)
    >
    > Look at not displaying 100's of rows but only 10-30 or so at a time
    > for this you would need some sort of paging stored proc.
    >
    > http://www.aspfaq.com/2120
    >
    > check out the last version listed using @@rowcount by Chris Hohmann
    > for this.
    >
    >
    > Also saving the info... will it be one save button at the bottom? or
    > one for each row ?
    >
    > eg
    >
    > <form ...>
    > line 1 ID: <input type="hidden" name="memID" value="1234">
    > line 1 name: <input type="text" name="memName" value="fred
    > flintstone">
    > line 1 age: <input type="text" name="memAge" value="32">
    >
    > line 2 ID: <input type="hidden" name="memID" value="1235">
    > line 2 name: <input type="text" name="memName" value="Wilma
    > flintstone">
    > line 2 age: <input type="text" name="memAge" value="28">
    >
    > line 3 ID: <input type="hidden" name="memID" value="1236">
    > line 3 name: <input type="text" name="memName" value="dino
    > flintstone">
    > line 3 age: <input type="text" name="memAge" value="4">
    >
    > <input type="submit" value="save all">
    > </form>
    >
    > by doing the above all the above info will be sent to the server in 3
    > "arrays"
    >
    > response.form("memID") would be "1234, 1235, 1236"
    > response.form("memName") "fred flintstone, wilma flintstone, dino ..."
    > response.form("memAge") "32, 28, 4"
    >
    > which you can then send to the DB stored proc and get that to update
    > the info. Since SQL servers dont have arrays as such then you would
    > need to check out the following page:
    >
    > http://www.sommarskog.se/arrays-in-sql.html
    >
    >
    >
    > If you have a save button for each entry.
    >
    > <form ...>
    > line 1 ID: <input type="hidden" name="memID" value="1234">
    > line 1 name: <input type="text" name="memName" value="fred
    > flintstone">
    > line 1 age: <input type="text" name="memAge" value="32">
    > <input type="submit" value="save">
    > </form>
    > <form ...>
    > line 2 ID: <input type="hidden" name="memID" value="1235">
    > line 2 name: <input type="text" name="memName" value="Wilma
    > flintstone">
    > line 2 age: <input type="text" name="memAge" value="28">
    > <input type="submit" value="save">
    > </form>
    > <form ...>
    > line 3 ID: <input type="hidden" name="memID" value="1236">
    > line 3 name: <input type="text" name="memName" value="dino
    > flintstone">
    > line 3 age: <input type="text" name="memAge" value="4">
    > <input type="submit" value="save">
    > </form>
    >
    >
    > Then the user will have to click it for each line he has changed. and
    > one line of info will be sent to the DB and updated, accordingly.
    >
    >
    > Next - the result... where to send the "save" result. well. since it
    > has to go to the server to send the info and to update the db, how are
    > you going to tell the user this has worked ok. Personally when I do
    > forms I (near) always put the DB updating code in the same for as the
    > displaying code. so the code for the above would look like this:
    >
    >
    > FILENAME.ASP.
    >
    >
    > 1) check to see if a form has been posted to this file.
    > 2) if not 1 skil step 3
    > 3a) if 1 then run function "updateDB()" or whatever.
    > 3b) if 2 ok tell user "info saved" or store in variable for later
    > display
    >
    > 4) get page data(ie the 20 rows to display)
    > 5) display page info to user.
    > 6) EOF.
    >
    >
    >
    > Other things to think about on the frontend, is what javascript you
    > might want to make it easier for the user. eg. how about disabling the
    > save button and only enable it when the user actually changes some
    > text? or if your doing a SaveALL then you could have another hidden
    > entry like the MemID which is just 1 or a 0 and set it to 1 when the
    > user has changed any info, then in the DB stored proc you only need to
    > update the rows where this value is a 1.
    >
    >
    > good luck.
    >
    > HTH.
    >
    > Al
    >

    -----------------------
    There will only be about 6 users who can access the page. I was planning on
    one save button. But after considering all the possibilities, I think it's
    best if I just let them connect with ODBC and use Access as a frontend on
    everyone's desktop. The end effort is to enable these 6 people to edit one
    single table of data without downloading and passing it around the country
    for everyone's edits. Also, they will need the capability of running
    reports. Access will be easiest to handle this.

    I still want to try the above though. Your suggestions will help on other
    projects.
    thanks!
     
    shank, Aug 29, 2004
    #5
    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. sanju
    Replies:
    0
    Views:
    402
    sanju
    Dec 18, 2006
  2. mesut
    Replies:
    0
    Views:
    698
    mesut
    Feb 19, 2007
  3. Erik Lautier

    Update Multiple Datagrid Rows

    Erik Lautier, Apr 8, 2008, in forum: ASP .Net
    Replies:
    1
    Views:
    535
    Erik Lautier
    Apr 8, 2008
  4. Memi

    Update Multiple Rows in GridView

    Memi, May 19, 2005, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    784
  5. Ram

    Web Page to Update Multiple Rows from Grid

    Ram, Jul 9, 2006, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    155
Loading...

Share This Page