如何创建数据库来存储我使用ASP.NET创建的Survey的数据? [英] How do I create a database to store the data for my Survey that I've created using ASP.NET?
问题描述
目前我正在使用Visual Studio 2012中的ASP.NET进行一项调查。
但是,我不知道做数据库的过程,特别是代码,但是我知道如何创建表格以及放置代码的位置。
我的调查包括radiobuttonlists和评论框。
这就是我确实:
这是ASP.NET中的调查编码(WEB FORM):
< div class = FQA > 引用:< / div > < script type = text / javascript >
function btnSubmit_Click(){
alert( 感谢您参加本次调查!);
}
< / script >
< < span class =code-leadattribute> / head >
< ; body >
< h1 > 参加此调查并提供关于本网站的意见!< / h1 > ;
< 表格 id = form1 runat = server >
< div >
< table 类 = auto-style1 >
< tr >
< td class = auto-style2 > 1)在访问我们的网站之前,您知道吗?并且不要使用社交媒体?< / td >
< td >
< asp:RadioButtonList ID = rbl1 runat = server AutoPostBack = True RepeatDirection = 水平 RepeatLayout = 流程 >
< asp:ListItem > 是
< asp:ListItem > 否
< / td >
< / tr < span class =code-key单词>>
< tr >
< td class = auto-style2 > 2)您是否了解社交媒体?< < span class =code-leadattribute> / td >
< td >
< asp:RadioButtonList ID = rbl2 runat = 服务器 AutoPostBack = True RepeatDirection = 水平 RepeatLayout = 流量 >
< asp:ListItem > 是
< asp:ListItem > 否
< / td >
< / tr >
< tr >
< td class = auto-style2 > 3)您在使用社交媒体时遇到任何问题吗?< span class =code-keyword>< / td >
< td >
< asp:RadioButtonList ID = rbl3 runat = server AutoPostBack = True RepeatDirection = Horizontal RepeatLayout = 流程 >
< asp:ListItem > 是
< asp: ListItem > 否
< / td >
< / tr >
< tr >
< td class = auto-style2 > 4)我们的网站是否有助于您了解更多信息关于社交媒体?< / td >
< td >
< asp:RadioButtonList ID = rbl4 runat = server AutoPostBack = True RepeatDirection = 水平 RepeatLayout = 流程 >
< asp:ListItem > 是
< asp:ListItem > 否
< / td >
< / tr >
< tr >
< td class = auto-style2 > 5)您是否会将您的网站分享给您的朋友?< / td >
< td >
< asp:RadioButtonList ID = rbl5 runat = server AutoPostBack = True RepeatDirection = 水平 RepeatLayout = 流程 >
< asp:ListItem > 是
< asp:ListItem > 否
< / td < span class =code-keyword>>
< / tr >
< tr >
< td class = auto-style2 > 6)有任何意见或建议吗?< ; / td >
< td >
< asp:TextBox ID = tbComment runat = 服务器 高度 = 182px TextMode = MultiLine 宽度 = 271px >
< br / >
< br / >
< br / >
< 输入 type = 按钮 onclick = btnSubmit_Click() value < span class =code-keyword> = 提交 / > < asp:按钮 ID = btnSubmit1 runat < span class =code-keyword> = server 文本 = 提交 / >
< asp:按钮 ID = btnReset runat = 服务器 OnClick = btnReset_Click 文字 < span class =code-keyword> = 重置 / >
< / td >
< / tr >
< / table >
< / div >
< / form >
然后,我尝试创建3个表在数据库中...
1)表答案:
< div class = FQA > 跨度>引用:<跨度class =code-keyword>< / div > CREATE TABLE [dbo ]。[tblAnswer]
(
[ansid] INT NOT NULL PRIMARY KEY,
[qID] INT NOT NULL,
[offerAnsID] VARCHAR(MAX)NOT NULL,
[userid] VARCHAR(MAX)NOT NULL,
[otherText] VARCHAR(MAX)NOT NULL
)
2)表格问题:
< < span class =code-leadattribute> div class = FQA > 引用:< / div > CREATE TABLE [dbo]。[tblQues]
(
[qId] INT NOT NULL PRIMARY KEY,
[qText] VARCHAR(200)NOT NULL,
[other] VARCHAR(2000)N OT NULL,
[status] VARCHAR(MAX)NOT NULL,
[total] VARCHAR(MAX)NOT NULL
)
3)QuesAns表 - 回答问题的选项
< div class = FQA > Quote:< / div > CREATE TABLE [dbo]。[tblQuesAns]
(
[Id] INT NOT NULL PRIMARY KEY,
[qID] INT NOT NULL,
[anstext] VARCHAR(200 )NOT NULL,
[anscount] VARCHAR(MAX)NOT NULL
)
然后我该如何继续?
[由adriancs编辑]用pre [替换blockquote [/ adriancs编辑]
我个人会从网络(C#,ASP.Net)代码中进行任何数据库操作。数据库是应用程序的单独组件。只是认为明天可以用另一种移动应用程序以完全不同的语言使用这些数据。
如果你对安装感到不满,我只想添加说明来创建一个新的数据库,然后添加你的创建表脚本。
要了解如何使用脚本创建数据库,请参阅以下内容:
http://msdn.microsoft.com/en-us/library/ms176061.aspx [ ^ ]
Hi, currently I'm working on a survey by using ASP.NET in visual studio 2012.
However, I don't know the process of doing the database, especially the codes, but I know how to create tables and where to put the codes.
My survey consists of radiobuttonlists and comment box.
This is what I did:
This is the coding for the survey in ASP.NET(WEB FORM):
<div class="FQA">Quote:</div> <script type="text/javascript">
function btnSubmit_Click() {
alert("Thank you for taking this survey!");
}
</script>
</head>
<body>
<h1>Take this survey and give us your opinions about this website!</h1>
<form id="form1" runat="server">
<div>
<table class="auto-style1">
<tr>
<td class="auto-style2">1) Before visiting our website, did you know the do's and don'ts of using social media?</td>
<td>
<asp:RadioButtonList ID="rbl1" runat="server" AutoPostBack="True" RepeatDirection="Horizontal" RepeatLayout="Flow">
<asp:ListItem>Yes
<asp:ListItem>No
</td>
</tr>
<tr>
<td class="auto-style2">2) Are you knowledgeable about social media?</td>
<td>
<asp:RadioButtonList ID="rbl2" runat="server" AutoPostBack="True" RepeatDirection="Horizontal" RepeatLayout="Flow">
<asp:ListItem>Yes
<asp:ListItem>No
</td>
</tr>
<tr>
<td class="auto-style2">3) Do you have any problems using social media?</td>
<td>
<asp:RadioButtonList ID="rbl3" runat="server" AutoPostBack="True" RepeatDirection="Horizontal" RepeatLayout="Flow">
<asp:ListItem>Yes
<asp:ListItem>No
</td>
</tr>
<tr>
<td class="auto-style2">4) Does our website help you understand more about social media?</td>
<td>
<asp:RadioButtonList ID="rbl4" runat="server" AutoPostBack="True" RepeatDirection="Horizontal" RepeatLayout="Flow">
<asp:ListItem>Yes
<asp:ListItem>No
</td>
</tr>
<tr>
<td class="auto-style2">5) Would you share our website to your friends?</td>
<td>
<asp:RadioButtonList ID="rbl5" runat="server" AutoPostBack="True" RepeatDirection="Horizontal" RepeatLayout="Flow">
<asp:ListItem>Yes
<asp:ListItem>No
</td>
</tr>
<tr>
<td class="auto-style2">6) Any comments or suggestions?</td>
<td>
<asp:TextBox ID="tbComment" runat="server" Height="182px" TextMode="MultiLine" Width="271px">
<br />
<br />
<br />
<input type="button" onclick="btnSubmit_Click()" value="Submit" /> <asp:Button ID="btnSubmit1" runat="server" Text="Submit" />
<asp:Button ID="btnReset" runat="server" OnClick="btnReset_Click" Text="Reset" />
</td>
</tr>
</table>
</div>
</form>
Then, I've tried creating 3 tables in database...
1) table Answer:
<div class="FQA">Quote:</div>CREATE TABLE [dbo].[tblAnswer]
(
[ansid] INT NOT NULL PRIMARY KEY,
[qID] INT NOT NULL,
[offerAnsID] VARCHAR(MAX) NOT NULL,
[userid] VARCHAR(MAX) NOT NULL,
[otherText] VARCHAR(MAX) NOT NULL
)
2) table for Question:
<div class="FQA">Quote:</div>CREATE TABLE [dbo].[tblQues]
(
[qId] INT NOT NULL PRIMARY KEY,
[qText] VARCHAR(200) NOT NULL,
[other] VARCHAR(2000) NOT NULL,
[status] VARCHAR(MAX) NOT NULL,
[total] VARCHAR(MAX) NOT NULL
)
3) table for QuesAns- the options for answering the question
<div class="FQA">Quote:</div>CREATE TABLE [dbo].[tblQuesAns]
(
[Id] INT NOT NULL PRIMARY KEY,
[qID] INT NOT NULL,
[anstext] VARCHAR(200) NOT NULL,
[anscount] VARCHAR(MAX) NOT NULL
)
Then how do I continue?
[edited by adriancs]Replace blockquote with pre[/edited by adriancs]
I personally would do any database manipulation from the web (C#, ASP.Net) code. Database is a seperate component of your application. Just think that the data can tomorrow be consumed by another mobile app in totally different language.
If you are concerened about installation, I would just add instructions to create a new database and than add your create table scripts.
To look how to create database using script, please see below:
http://msdn.microsoft.com/en-us/library/ms176061.aspx[^]
这篇关于如何创建数据库来存储我使用ASP.NET创建的Survey的数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!