I am creating an order form using C# OleDb and am having an issue with attempting to put the size value from a combo box in the order form into the database. The code that causes the issue is below.
private void btn_Save_Click(object sender, EventArgs e)
{
try
{
connection.Open();
OleDbCommand command = new OleDbCommand();
command.Connection = connection;
command.CommandText = "insert into OrderForm(Size) values ('" + sizeBox.Text + "')";
command.ExecuteNonQuery();
MessageBox.Show("Order Inserted into Database");
connection.Close();
}
catch (Exception ex)
{
MessageBox.Show("Error " + ex);
}
}
This is the only piece of code that is causing me an issue and i've compared it to my other commandText lines of code that i've commented out to ensure that the syntax is correct and it looks okay to me. I have also checked to ensure that the field name listed into the commandText code and the field in the actual database are correct and it is. Any help on this issue will be greatly appreciated. Cheers
Edit: Syntax Error that the code is giving me