Using Access database like this :
OleDbConnection conn = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0; Data Source=" + Request.PhysicalApplicationPath + "Resources/cars_db.accdb");
conn.Open();
OleDbCommand cmd = conn.CreateCommand();
cmd.CommandText = "INSERT INTO Users (Username, Password, Email, Address, Question, Answer) VALUES ('" + txtUsernameRP.Text + "','" + txtPasswordRP.Text + "','" + txtEmailRP.Text + "','" + txtAddressRP.Text + "','" + txtQuestionRP.Text + "','" + txtAnswerRP.Text + "')";
int i = cmd.ExecuteNonQuery(); -- **Breaks here and says syntax error**
I have tried:
- Taking out the int i bit.
- Putting the @ symbol in front of the statement.
- Checked and made sure that I am using the Access code.
- Tried closing the connection before creating in case it was something there.
- Substituted the data for fixed values, which I then ran in a query in Access which worked.
- Put the access query mentioned above into the code block (cmd.CommandText = "INSERT INTO Users (Username, Password, Email, Address, Question, Answer) VALUES ('asdasd','Asd!23asd','asdasd','asdasd','asdasd','asdasd')"; and tried running it and again same syntax error.
Please someone help me...