SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["cn"].ConnectionString); con.Open(); Int32 code = Convert.ToInt32(TextBox1.Text); String name = TextBox2.Text;
SqlCommand cmd = new SqlCommand(); cmd.CommandType = CommandType.Text; cmd.CommandText = "insert into tbmem (memcod,memnam) values (@code,@name)" ; cmd.Connection = con; cmd.ExecuteNonQuery(); cmd.Dispose(); con.Close();
Error : must declare @code scalar variable
Thanks