I am developing a very small survey application, likely 3-4 pages web application. so my question is what is the best way to save survey data?
by the way so far I have come up with the following ways.
save to database and mark each survey as incomplete. when user submits last form of the survey check completeness of the survey and mark it as complete if it is complete.
save to sessions and than save to database when user submits last form of the survey.
what do you think about those methods?
I've had quite some headaches with this sort of thing and would advise against using Sessions if at all possible. When your site gets moderately heavy traffic, or if ASP.NET just feels like it, you may find you lose all your sessions as .NET tries to free up some memory.
I'd go for putting it in the database as soon as possible. Use Guid.NewGuid() to generate a unique unguessable key that you can pass from one page to the next in the query string: that'll be your key to retrieving the record from the database.
Two other options you haven't considered:
Post the response from one page to the next. (This might be more hassle than it's worth.)
Use the asp:Wizard control. That way your 3-4 pages will actually be 3-4 steps on a single page. The data from each stage is automatically stored in the ViewState for you, so the input fields from the first step will still be accessible to you when you're on the last step.
(I'd still go for your option number 1 though.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With