Click here to Skip to main content
12,752,876 members (38,380 online)
Rate this:
Please Sign up or sign in to vote.
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.
Posted 24-Dec-12 6:55am
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Look here,[^]

To insert 6 records use a for loop for the number of records[^]
Member 8197993 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,
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

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.

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

    Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170217.1 | Last Updated 24 Dec 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100