TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Guest User
Tech Writer
357
120.8k
A Textbox value broken down into individual values and persisted to Database, one per row.
May 11 2012 6:26 AM
Hi
I have a Textbox which holds a numeric value from 0-9999 to determine the Quantity of an item.
Rather than persisting a value of say 9999 to the Quantity column of the DB, I would like to iterate through each value and persist to the DB in seperate rows.
I was thinking of going down the lines of getting the quantity and storing in a local variable say totalQuantity.
int totalQuantity = 0;
totalQuantity += item.Quantity;
// result of totalQuantity is now 9999
for(int = 0; i < totalQuantity; i++)
{
// Not sure how to get each [i] value and store?
}
OrderDetail od = new OrderDetail();
od.Quantity = ?
// The ? should persist to Quantity DB field over and over until 9999 is reached.
(My DB fields cannot be Null so id have to use the same data for the other columns)
Im hoping there is an easier way than to create a new OrderDetail instance\object and set the Quantity property over and over, maybe something like:-
od.Quantity += totalQuantity;
Or maybe a list of numeric values which are then persisted back to the DB in one wrapped transaction!?
Thanks
Steven
Reply
Answers (
10
)
Jagged Arrays
What is the difference between Array and ArrayList?