-2

I want to insert multiple records into the database at a single button click. I have a textbox, and when the user enters 3 into the textbox, 3 rows should be inserted into the database. How should I do this. Please help out. Thank you.

user2782692
  • 99
  • 1
  • 1
  • 4
  • Please help, I really want to do it but dont know how. – user2782692 Jul 17 '14 at 04:52
  • [link](http://stackoverflow.com/questions/2624713/how-do-i-insert-multiple-rows-without-repeating-the-insert-into-dbo-blah-part). Doesnt this help? @user2782692 – sun_dare Jul 17 '14 at 04:53
  • You can't just tell us that you don't know how to do. You have to show the code you already have. This is not a gimme-my-code service. – Lorenz Meyer Jul 17 '14 at 04:58
  • 1
    3 rows with what data??Please post the target database table and elaborate more your required input and output.. – Deepshikha Jul 17 '14 at 04:59
  • which database you are using?? – Ankit Bajpai Jul 17 '14 at 05:03
  • ok I will provide a snapshot of what i am doing: – user2782692 Jul 17 '14 at 05:07
  • I have a textbox and a hidden field for random number generation. When the user enters an number in the textbox and clicks the save button, that many records are generated and saved in the database. I am sorry but I am unable to display the snapshot – user2782692 Jul 17 '14 at 05:15

1 Answers1

0

In MYSQL only it is possible with somthing like this:-

INSERT INTO TAB_NAME(COL1, COL2) 
VALUES(VALUE1, VALUE2), 
      (VALUE1, VALUE2), 
      (VALUE1, VALUE2), 
      (VALUE1, VALUE2), 
      (VALUE1, VALUE2);

Above command will insert 5 ros to databse at a time simultaneously.

Ankit Bajpai
  • 13,128
  • 4
  • 25
  • 40