Submitting form results to a database
Posted on 2006-07-07
I have a long background in FrontPage which I've now gotten away from. I'm now using Visual Studio 2005's Visual Web Developer. One thing I can say for FP is that it was purely point and click simple to post form results to a databaes. I'm just not getting something using asp.net.
I have a survey form with 8 questions having 6-5 choice radio button based (not optional) and two text boxes (optional). I want to use the form only for entering new survey results - not to display any results at all. I'm connecting to a MSSQL 2000 database. What is the easiest method by which to accomplish this?
Here is my connection string:
<asp:sqldatasource id="SqlDataSource1" runat="server" connectionstring="<%$ ConnectionStrings:SurveysConnectionString %>"
selectcommand="SELECT [surveyID], [q1], [q2], [q3], [q4], [datecomp], [email], [comments], [q6], [q5] FROM [ITCustSatisfaction] ORDER BY [surveyID], [datecomp]" insertcommand="INSERT INTO [Surveys].[dbo].[ITCustSatisfaction] ([surveyid],[q1],[q2],[q3],[q4],[q5],[q6],[comments],[email],[datecomp]) VALUES (surveyid, q1.SelectedValue, q2.SelectedValue, q3.SelectedValue, q4.SelectedValue, q5.SelectedValue, q6.SelectedValue, comments, email, datecomp)">
I tried setting it up using the wizard where it automatically generates the INSERT, DELETE AND UPDATE statements, but they were always greyed out and I couldn't get there from here.
[surveyid] is a hidden field on the web form and is an autogenerated number in the sql db. Q1-Q6 can be any number from 1-5 and each question is a separate radio button group list. I don't have any asp.net errors on the page right now. I'm at the point where when the user clicks "submit" I want the results posted to the db and have them directed to a surveysubmitted page (this one isn't created yet, but I can create it as an aspx page or htm, whichever it needs to be.)
Thanks for any pointers to the right direction...