存储调查数据的最佳方式? [英] best way to store survey data?

查看:31
本文介绍了存储调查数据的最佳方式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个非常小的调查应用程序,可能有 3-4 页的 Web 应用程序.所以我的问题是保存调查数据的最佳方法是什么?

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. 保存到数据库并将每个调查标记为未完成.当用户提交调查的最后一个表格时,检查调查的完整性,如果完成则将其标记为完成.

  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.

保存到会话,然后在用户提交调查的最后一个表格时保存到数据库.

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

您如何看待这些方法?

推荐答案

我对这类事情感到很头疼,如果可能的话,我建议不要使用 Sessions.当您的网站流量适中,或者 ASP.NET 只是感觉如此时,您可能会发现您丢失了所有会话,因为 .NET 会尝试释放一些内存.

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.

我会尽快将其放入数据库.使用 Guid.NewGuid() 生成一个唯一的不可猜测的键,您可以将其从查询字符串中的一页传递到下一页:这将是您从数据库中检索记录的键.

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. 将响应从一页发布到下一页.(这可能比它的价值更麻烦.)

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

使用 asp:Wizard 控件.这样,您的 3-4 页实际上将是单个页面上的 3-4 个步骤.来自每个阶段的数据会自动为您存储在 ViewState 中,因此当您进行最后一步时,您仍然可以访问第一步中的输入字段.

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.

(不过我还是会选择你的选项 1.)

(I'd still go for your option number 1 though.)

这篇关于存储调查数据的最佳方式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆