Jagjit Saini

Jagjit Saini

  • NA
  • 166
  • 0

Unable to Add Record

Jun 20 2011 11:29 AM

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



Answers (1)