Click here to Skip to main content
13,406,671 members (48,862 online)
Rate this:
Please Sign up or sign in to vote.
See more: , +
In my application i have a web page where i have to answer nearly 60 sums. Each sum have a textbox(say txtSum1,txtSum2....) to answer. I have to insert these sums answer to Database. Normally how i do is (for 10 sums) i created 10 columns in a table and names as sum1,sum2,sum3.... ...and insert the sum1 answer to sum1 column and so...But for 60 sums it is not a good method.. plz tell me how to insert these 60 sums value to database(just tell me what are the colunms i needed. Should i create 60 columns or any other method).
Posted 20-Jan-13 21:39pm
Updated 20-Jan-13 21:54pm
sisir patro 21-Jan-13 3:04am
This is wrong of adding 60 columns in the database. Do you want to show the sum of the text fields or save the sum in database?
shamjid 21-Jan-13 5:14am
no need to get sums of text fields. what i need is i have to save the answer of each question to check whether he typed correct answer or not...each sum ll have a default answer..

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

It really depends on what you want to do with them later.

Since there are always 60 text boxes, (although that's a lot for a user to cope with in one go, I'd consider cutting them down to six pages of ten or so) I would probably go with the "60 columns in a row" approach, if I needed to do any arithmetic ot calculation on they values later. If I was just keeping them for reference, then I would probably use a single column, and concatenate the answers together into a single CSV value.

The only other approach is to have a whole separate table with a row per text box, each row having a ID linkiing it back to the original page row and some indication of the textbox number. Nasty, and wasteful.
sisir patro 21-Jan-13 3:43am
How about storing the basic info in a table and optimizing the query for the calculation of the sum.
sisir patro 21-Jan-13 3:45am
My +5...
OriginalGriff 21-Jan-13 3:50am
Same thing - you either need sixty columns somewhere, or a single column with all results.
You gotta store something somewhere! :laugh:
sisir patro 21-Jan-13 3:58am
shamjid 21-Jan-13 5:20am
i actually cut this to 2 pages..Thatis 30 question in a page and i decided to create a page Id...from question 1 - 30 i save it in page Id 1 and remaining as i just have to create 30 columns...
sisir patro 21-Jan-13 5:29am
Keep a separate table for the 60 qusetions as instructed by Griff.
OriginalGriff 21-Jan-13 5:33am
Better - It may be that 30 is still too many - I don't know how your page(s) look so I can't be sure. It's better not to overwhelm the user with inputs though - it can get depressing and look like "hard work" if there are too many on a page. And look patronising if there are too few! :laugh:

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 |
Web02-2016 | 2.8.180212.1 | Last Updated 21 Jan 2013
Copyright © CodeProject, 1999-2018
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