Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Jun 2002
    Posts
    358
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Unhappy textbox in loop add into database.... in ASP

    dear,

    i'm using ASP + SQL Server 2000.
    i hav a page, i retrieve almost 100 records from database and shown all the record description with 2 textboxes for each records(Total is 200 textboxes) to allow user add value,
    when i gonna save the text boxes that with value, do i need to loop 100 times to check the value is empty or not, then only i save into database?

    any solution that can reduce the processing time? can i use check box with it?
    Thanks.
    =====================================================
    From NinjaTurtle
    ++http://ohmygoh.blogspot.com|http://technology.ohmygoh.com++

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Location
    Cincinnati, OH
    Posts
    545
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I would add a checkbox for each record with the same name and let the value be the ID of each row. Then on the server side loop through your checkbox collection and update your db. This way you are only updating the affected records not all 100 of them.

  • #3
    Regular Coder
    Join Date
    Jun 2002
    Location
    Round Rock, Texas
    Posts
    443
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Then on the server side loop through your checkbox collection and update your db.
    Allida77;
    That's THE problem (for me anyway).

    I'm trying to loop through <option>s in a <select> object (no prob. looping through them) and stuff them into a database. I can't seem to make it happen. I'm calling a stored procedure. Do I use "recordset.execute" or "recordset.update" or outside the loop use "recordset.updatebatch?" And HOW? I do not understand enough about the interaction/complimentary nature of connection, command, recordset objects to make it work. And I guess that's what N.T. is asking about. I'm using a connection and recordset (no command). Why? Hell, I don't know!


    Oh, and BTW, N.T. ;
    request.form("checkbox_group_name").count will give you the # of checkboxes so u can use that as the terminator for your loop on the server-side.

    Also use request.form("checkbox_group_name")(x) to reference each checkbox inside the loop on the server-side.

    Also, note that ONLY the checkboxes that are "checked" are actually passed when SUBMITted. So my SUBMIT button calls a function that "checks" all the checkboxes (i.e formname.chkboxname[x].checked = true). It's the checkbox's value property that actually carries the info for me that goes into the database.
    Last edited by RadarBob; 08-09-2002 at 03:18 PM.

  • #4
    Regular Coder
    Join Date
    Jun 2002
    Location
    Cincinnati, OH
    Posts
    545
    Thanks
    0
    Thanked 0 Times in 0 Posts
    This is how I loop through my checkboxes to update my db.

    Request.Form("hdnID") is my collection of checked checkboxes.


    tskID = split(Request.Form("hdnID"), ",")

    For Each id in tskID
    rs.MoveFirst
    rs("Desc") = Request.Form("txtDesc")
    rs.Update
    Next


    As far as the stored procedures I would have to see more code. I do not get to work with them much


  •  

    Posting Permissions

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