I am learning to connect to Microsoft Access and write into the database. I created a database in Access and would like to insert data into it.
OleDbConnection conn = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Amin\Desktop\NamesDatabase1.accdb");
OleDbCommand cmd = new OleDbCommand();
string FN = textBox1.Text;
string LN = textBox2.Text;
cmd.CommandText = "INSERT INTO Names (FirstName, LastName) Values (FN,LN)";
cmd.Connection = conn;
conn.Open();
cmd.ExecuteNonQuery();
Before I run there seems to be no error. I run the program, update my textBox1.text
and textBox2.text
and press SAVE, then I get an error:
SYNTAX ERROR in SQL statement Insert into
What did I do wrong??