Sourabh Dhiman

Sourabh Dhiman

  • NA
  • 2
  • 709

Plzz Solve In this code error

Aug 17 2018 2:57 AM
SqlCommand cmd = new SqlCommand("insert into tblProduct(ProductID,Name,UnitPrice,QtyAvl)Values(@ProductID,@Name,@UnitPrice,@QtyAvl)", con);
cmd.Connection = con;
cmd.Parameters.Add("@ProductID", SqlDbType.Int).Value = TextBox1.Text;
cmd.Parameters.Add("@Name", SqlDbType.VarChar, 50).Value = TextBox2.Text;
cmd.Parameters.Add("@UnitPrice", SqlDbType.NVarChar, 50).Value = TextBox3.Text;
cmd.Parameters.Add("@QtyAvl", SqlDbType.NVarChar, 50).Value = TextBox4.Text;
cmd.ExecuteNonQuery();
SqlDataAdapter ds = new SqlDataAdapter();
DataTable dt = new DataTable();
ds.Fill(dt);
GridView2.DataSource = dt;
GridView2.DataBind();
cmd.Dispose();
con.Close();
what's error in code
 

Answers (6)