I'm stumped as to why this isn't working properly. Can someone shed some light? I am trying to insert a row into a database once a button is clicked.
This is the code segment I have right now.
ins_comm.CommandText = "INSERT INTO vehicles (make, model_name, model_year, engine_type, transmission_type) VALUES ('" + makeComboBox.Text + "', '" + modelComboBox.Text + "', '" + yearComboBox.Text + "', '" + engineComboBox.Text + "', '" + transTypeComboBox.Text + "')";
ins_comm.ExecuteNonQuery();
The connection stays open once the first combobox is filled in and it will stay open until the form is closed in some fashion. The connection is to a local database contained within the project and it is a CE edition db.
UPDATE:
This is my new code segment.
SqlCeCommand insert_command = new SqlCeCommand("INSERT INTO vehicles (make, model_name, model_year, engine_type, transmission_type) " + "VALUES (@make, @model_name, @model_year, @engine_type, @transmission_type)", conn);
insert_command.Parameters.AddWithValue("@make", makeComboBox.Text);
insert_command.Parameters.AddWithValue("@model_name", modelComboBox.Text);
insert_command.Parameters.AddWithValue("@model_year", yearComboBox.Text);
insert_command.Parameters.AddWithValue("@engine_type", engineComboBox.Text);
insert_command.Parameters.AddWithValue("@transmission_type", transTypeComboBox.Text);
create_adapt.InsertCommand = insert_command;
insert_command.ExecuteNonQuery();
I still do not see anything new in my db after running the program. Can anyone point me in the right direction as to what I'm missing?