Corrected your code. you were missing to assign the SqlConnection object to SqlCommand command object.
DialogResult dh = MessageBox.Show("DO YOU WANT TO INSERT ?", "CONFIRM YOUR INSERT", System.Windows.Forms.MessageBoxButtons.YesNo);
if (dh != DialogResult.No)
{
SqlCommand cmd = new SqlCommand("exec insertcatego @description,@quality,@quantity,@priceUnit,@vat,@totalprice", con);
cmd.Parameters.AddWithValue("@description", txtDesc.Text);
cmd.Parameters.AddWithValue("@quality", comboBoxQuality.SelectedValue.ToString());
cmd.Parameters.AddWithValue("@quantity", txtQant.Text);
cmd.Parameters.AddWithValue("@priceUnit", txtpUnt.Text);
cmd.Parameters.AddWithValue("@vat", txtVat.Text);
cmd.Parameters.AddWithValue("@totalprice", txtTotP.Text);
cmd.Connection=new SqlConnection("your connectionString here" );
con.Open();
cmd.ExecuteNonQuery();
frmcategory_Load(sender, e);
MessageBox.Show("SUCCESSFULL INSERT");
}
}
catch (Exception a)
{
MessageBox.Show(a.Message.ToString());
}
}
Good luck !!!