Click here to Skip to main content
15,667,014 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I need to insert a row in a table for the number a user enters into a text box.

example: user puts the number "6" into textbox, and clicks the button. I want it to insert 6 rows into the database table.

can anyone give me an example on how to do this.
sql database.
Updated 24-May-17 0:19am

Look here,[^]

To insert 6 records use a for loop for the number of records[^]
Share this answer
PTG.Jake 24-Dec-12 12:32pm    
Thanks Dino your second link helped me alot. I was stuck on trying to use a "do while". problem solved.
DinoRondelly 24-Dec-12 12:35pm    
Your welcome,
Here is a very good example of creating stored procedures to supply the future functionality of what your wanting to do on the SQL side of things HERE:[^]

Then depending on where your data is coming from could be in the Stored Procedure to collect the data for the values or you would have to send in that value.

On the C# side of things, you can do many different options to loop through the data needs:

While example:,d.aWM[^]

FOR supplied above but heres another: (Visual Studio version not relevent in this example)[^]

Foreach, Do etc... examples:[^]

Hope that helps.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900