I am trying to submit filledin information in the form to the database. I have done the below mentioned coding for the save button. When I click on the save button to save the information, I am getting an error. I need it to be done and for the same need help from the geeks around here.
COde for SAVE button data from database
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string conn = ConfigurationManager
.ConnectionString("welcome").ConnectionString;
SqlConnection con=new SqlConnection(conn);
SqlCommand cmd = new SqlCommand("Insert into abhishek(pr_name,Add,add2) values(@ah,@Ap,@qe)",con);
cmd.CommandType = CommandType.Text;
cmd.Parameter.Addwithvalue("@ah", TextBox1.Text.Trim());
cmd.Parameter.Addwithvalue("@ap", TextBox2.Text.Trim());
cmd.Parameter.Addwithvalue("@qe", TextBox3.Text.Trim());
con.Open();
cmd.ExecuteNonQuery();
con.Close();
}
}
Check the error in the image below:

You are missing an ‘s’ from the
ConnectionStringsindexed property. Once you fix that error, however, you will also find you are missing more ‘s’ from theSqlCommand.Parametersproperty.To reveal these issues, open Properties of your code-behind file, and choose Build Action of Compile. (Also, I can see from your image that it looks like your project is setup as a Web Site rather than a Web Application; if possible, look into converting this over to a Web Application, as it offers a number of benefits.)
Once you get your syntax corrected, then you should change your code so that the update is invoked through the button click handler, rather than on page load.
In your markup code in the aspx:
In your code-behind:
Note that I have moved the code into the button click event handler, and out of the Page_Load. The Load event handler should only be used for initialization items needed unconditionally on the execution path of the page (i.e., regardless of whatever button was clicked on the page), and should look something like the following: