Wednesday, February 16, 2011

Code to Insert Row in DatBase

SqlConnection con= new SqlConnection(@"Data Source=.\SQLEXPRESS;Initial Catalog=datas;Integrated Security=True");
SqlCommand cmd=new SqlCommand ("insert into table1 (mname, initial, email,color,address, mphone,city) values ('" +txtname.Text +"' +txtinitial.Text+ "' + txtemail.Text "'+ txtcolor.Text+"' +txtaddress.Text+"' +txtphn.Text + "' +txtcity.Text +"')",con);
con.Open();
cmd.ExecuteNonQuery();
con.Close();

No comments:

Post a Comment