Jyoti Jodha

Jyoti Jodha

  • NA
  • 1.7k
  • 406.9k

how to fill combobox in c# windows application from database

Mar 25 2017 8:22 AM
cmd = new SqlCommand("insert into Additem(Product_Name,Description,Qty,Unit_Price,Tax) values(@Product_Name,@Description,@Qty,@Unit_Price,@Tax)", con);
con.Open();
cmd.Parameters.AddWithValue("@Product_Name", producttxt.Text);
cmd.Parameters.AddWithValue("@Description", destxt.Text);
cmd.Parameters.AddWithValue("@Qty", qtytxt.Text);
cmd.Parameters.AddWithValue("@Unit_Price", unitxt.Text);
cmd.Parameters.AddWithValue("@Tax", comboBoxtax);
//cmd.Parameters.AddWithValue("@Tax",comboBoxtax.GetItemText(comboBoxtax.SelectedItem));
cmd.ExecuteNonQuery();
con.Close();
MessageBox.Show("Record Inserted Successfully");
DisplayData();
ClearData();

Answers (9)