Question by ~*♥*~Ashley Star~*♥*~: Can someone help me with this ASP.NET web form?
It is my duty to create a website to allow users to submit their software update requests. However it has been about a year and a half since I’ve worked with ASP.NET so I am kinda drawing a blank. I am wanting to have a web form where users can fill out information and hit “Add request” button. When they do this I would like the information from the text boxes to be inserted into the user request database. Am I needing to user stored procedures or what? Just keep in mind this will be an on going website so fixing it up for “easy maintenance ” would help. Thank you!!
oh yeah! i’m doing this in C# by the way
and we use MS Server 2003
i tried that and when i go to build it gives me an error for “SqlConnection” do I need to replace that with something different?
Answer by Rex M
You need to add an OnClick event handler to your submit button. That method should have your logic to insert your data into the DB.
SqlConnection dbConn = new SqlConnection( “connectionstring” );
SqlCommand cmdIns = new SqlCommand(“INSERT INTO tblRequests (Name, Info, Other) VALUES(@name, @info, @other)”, dbConn);
cmdIns.Parameters.Add( “@name”, txtName.Text);
cmdIns.Parameters.Add( “@information”, txtInfo.Text);
cmdIns.Parameters.Add( “@other”, txtOther.Text);
Give your answer to this question below!