# Miscellaneous > SQL Scripts >  Inserting multiple records

## brakes

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.

----------


## MAK

yo u have to loop through all the checkboxes and execute sql statement for every check box.

----------


## brakes

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?

----------


## MAK

please post your code here. let me take a look.

----------


## brakes

=======================================
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

----------

