Click here to Skip to main content
15,894,405 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
I am working on a web application that requires no database interaction. I am only allowed to store the results of the user's form entry as an email. The web application itself is like a survey that asks a bunch of questions, some of which require explanations. When the survey is completed, the questions and answers are then sent through email to the surveyor.

My question, what is the best way to save the questions' text and answers so that they do not need to be hard-coded into the application? I've used resource files before and they would work for this application but I'd wanted to see if anyone had a better solution they would like to share. I am not looking for a database solution.

Thanks!
Posted
Comments
Albin Abel 15-Mar-11 9:14am    
XML is an alternate
R. Giskard Reventlov 15-Mar-11 9:17am    
You should offer this as the solution: you'd get my 5.
bwhittington 15-Mar-11 11:18am    
Thank you for your response. I've worked with a couple of test questions using "Option 2" and I like the results. Unfortunately, I can't post my examples for others because its work related but hopefully your options help others as well.
Albin Abel 15-Mar-11 11:39am    
Thanks Digital man. Thanks bwhittington
Sergey Alexandrovich Kryukov 15-Mar-11 21:23pm    
I think this is a good question, applicable in certain situation. Please see my Answer.
--SA

Option 1) Have object which holds your questions structure. serialize it into XML. The adavantage would be you can edit the XML also you can easily access its contents through a deserialized object. If you use collection object then you need to use the DataContractSerializer

Option 2) Have an XML structured for your questions, Populate it to Dataset using ReadXml() method.

Option 3) Open to you. CSV, Excel, Formatted text file etc.,
 
Share this answer
 
Comments
Espen Harlinn 15-Mar-11 15:12pm    
Reasonable options, my 5
Albin Abel 15-Mar-11 15:30pm    
Thank you very much Espen Harlinn
Sergey Alexandrovich Kryukov 16-Mar-11 16:58pm    
That is right, my 5. I posted a way of serialization, in my opinion, the best, please see.
Teamwork? :-)
--SA
In my opinion, the most beneficial way (by far the most) is this: create some pure-data classes and make some data graph (does not have to be tree, can be a more general-structure graph) to express your data model and store/load it using Microsoft Data Contract.

This way is very non-intrusive and robust. You only add [DataContract] attributes to your types and [DataMember] to your members. System.Runtime.Serialization.DataContractSerializer does the trick. Don't forget to set up your unique company name space in DataContract — the auto-generated XML meta-data (and hence your data format) will be recognized as world-unique.

See System.Runtime.Serialization.DataContractAttribute, System.Runtime.Serialization.DataMemberAttribute and System.Runtime.Serialization.DataContractSerializer, http://msdn.microsoft.com/en-us/library/system.runtime.serialization.datacontractserializer.aspx[^]

—SA
 
Share this answer
 
Comments
Espen Harlinn 16-Mar-11 13:53pm    
Nice reply - 5ed!
Sergey Alexandrovich Kryukov 16-Mar-11 16:56pm    
Thank you very much.
--SA

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