Click here to Skip to main content
15,895,746 members
Articles / Web Development / ASP.NET

About insert value in database

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
25 Jan 2013CPOL 0  
The SqlCommand calling the ExecuteNonQuery() method only has 1 "m" while you declared it with 2. com.ExecuteNonQuery() should be comm.ExecuteNonQuery()Also, I would declare your SqlConnection in the same scope your other code is in.

Alternatives

Members may post updates or alternatives to this current article in order to show different approaches or add new features.

Please Sign up or sign in to vote.
25 Jan 2013Member 9785676 2 alternatives  
public partial class Home : System.Web.UI.Page{ SqlConnection con = new SqlConnection("Data Source=LENOVO-PC\\SQLEXPRESS;Initial Catalog=employee;Integrated Security=True"); protected void Page_Load(object sender, EventArgs e){} protected void Button1_Click(object sender,...
Please Sign up or sign in to vote.
25 Jan 2013Mike Meinz
Your INSERT statement is missing the names of the columns. Best practice is to include the names of the columns so that your SQL statements will work should someone later add one or more columns to the database table. INSERT INTO EMPLOYEE (col1,col2,col3)...

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
United States United States
I have been on my software developing journey since May 2011. I was dumbfounded at the shear amount of information involved when first starting out but have become comfortably numb to it.

My base knowledge is in ASP.Net and C#, but I am continuously expanding upon that.

I am now a SharePoint Engineer and have been working with AngularJS, REST api, and the new app model for SharePoint, both provider hosted and SharePoint hosted.

Comments and Discussions