Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

best way to store survey data?

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.

  1. 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.

  2. save to sessions and than save to database when user submits last form of the survey.

what do you think about those methods?

like image 552
Mohamed Avatar asked Mar 01 '23 00:03

Mohamed


1 Answers

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:

  1. Post the response from one page to the next. (This might be more hassle than it's worth.)

  2. 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.)

like image 53
teedyay Avatar answered Mar 05 '23 16:03

teedyay