Results 1 to 5 of 5

Thread: Inserting multiple records

  1. #1
    Join Date
    Nov 2003
    Posts
    12

    Inserting multiple records

    i have a form in html which uses textboxes(fieldname=mobilecode) as its input type. upon clicking the submit button, the checked items would add to the user's personal data in my database. here is the code:


    sql_send= "insert into tblprofiles
    (mobilecode, status)
    values ('" & request("chkmcode")
    & "' , 'cleared')"


    the code works if only one checkbox is marked. but if it exceeds 1, the page gets an error (something like data is truncated). can i really insert n number of "mobilecode" with one similar "status" for all of them? please help. thanks in advance.

  2. #2
    Join Date
    Sep 2002
    Location
    Fantasy
    Posts
    4,254
    yo u have to loop through all the checkboxes and execute sql statement for every check box.

  3. #3
    Join Date
    Nov 2003
    Posts
    12
    yes i did try to loop on the checkbox array. i used do while but it did not work. can yo show me an example. pls?

  4. #4
    Join Date
    Sep 2002
    Location
    Fantasy
    Posts
    4,254
    please post your code here. let me take a look.

  5. #5
    Join Date
    Nov 2003
    Posts
    12
    =======================================
    CODE IN HTML FILE
    =======================================

    Response.Write "<input type=checkbox name=chkSend value=" & rscontact("celnum")& ">"


    ========================================
    CODE IN ASP FILE
    ========================================

    sql_send= "insert into tbloutgoing (vcmobileno, vcmessage) values ('" & request("chksend") & "' , 'status cleared')"
    set conn = server.createobject("adodb.connection")
    conn.open strconn
    conn.execute (sql_send)

    conn.close
    set conn=nothing


    i tried to count how many records where checked and loop it to the insert command but it won't work either. the code in the asp file goes like this:

    n=request("chksend").count
    n=0
    do while request("chksend").count<>n
    [insert command
    loop

Posting Permissions

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