再び。これが私のコードです。エラーは、フォームを使用してデータベースにデータを追加しているときに、コンボボックスに失望することです。
誰でもここで私を助けてくれますか。問題は、この行「com.Parameters.AddWithValue("@ProductCategory", cmbProductCategory.SelectedItem.ToString());」にあります。
SqlCeCommand com = new SqlCeCommand("INSERT INTO Products_Master(ProductCode, ProductName, ProductDescription, ProductCategory, LandingPrice, SellingPrice, Stock) VALUES(@ProductCode, @ProductName, @ProductDescription, @ProductCategory, @LandingPrice, @SellingPrice, @Stock)", con);
com.Parameters.AddWithValue("@ProductCode", txtProductCode.Text);
com.Parameters.AddWithValue("@ProductName", txtProductName.Text);
com.Parameters.AddWithValue("@ProductDescription", txtProductDescription.Text);
com.Parameters.AddWithValue("@ProductCategory", cmbProductCategory.SelectedItem.ToString());
com.Parameters.AddWithValue("@LandingPrice", txtLandingPrice.Text);
com.Parameters.AddWithValue("@SellingPrice", txtSellingPrice.Text);
com.Parameters.AddWithValue("@Stock", txtStock.Text);
try
{
int affectedRows = com.ExecuteNonQuery();
if (affectedRows > 0)
{
System.Windows.Forms.MessageBox.Show("Insert Success !", System.Windows.Forms.Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);
txtCategoryName.Text = "";
Category_Master_Changed();
}