我尝试使用下面的代码将标签值插入MS Access,但我不断收到“插入语句中的语法错误”。请任何人帮忙。感谢
private void button1_Click(object sender, EventArgs e)
{
label2.Text = "Born To Win";
label4.Text = "£10";
connection = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data source =C:\Users\Kunle\Documents\Winners App\winnersBookShop.accdb;Persist Security Info=False");
connection.Open();
OleDbCommand command = new OleDbCommand();
command.Connection = connection;
try
{
command.CommandText = "INSERT INTO Transaction([Title], [Price]) VALUES('" + label2.Text + "','" + label4.Text + "')";
command.CommandType = CommandType.Text;
command.ExecuteNonQuery();
MessageBox.Show("Successfully");
}
catch (Exception r)
{
MessageBox.Show("Unsuccesssful" + r);
}