Click here to Skip to main content
15,897,891 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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
Updated 20-Jan-13 20:54pm
v3
Comments
[no name] 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

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.
 
Share this answer
 
Comments
[no name] 21-Jan-13 3:43am    
How about storing the basic info in a table and optimizing the query for the calculation of the sum.
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:
[no name] 21-Jan-13 3:58am    
Yes...
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 2..so i just have to create 30 columns...
[no name] 21-Jan-13 5:29am    
Keep a separate table for the 60 qusetions as instructed by Griff.

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