views:

20

answers:

1

I have an MDB file I access using OleDB:

OleDbConnection connection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\Database.mdb;Persist Security Info=True");

And try to create a new row in a table Users:

connection.Open();
OleDbCommand cmd = new OleDbCommand("INSERT INTO `users` (`name`, `password`) VALUES ('asd', 'asd')", connection);
cmd.ExecuteNonQuery();
connection.Close();

But nothing happens. I don't get an error message or exceptions, it runs without problems. But when I check the database after the program finished, the table still is empty.

(I already tried the same using DataSets and TableAdapters, but the same happened there: http://stackoverflow.com/questions/3334632/inserting-not-commited-to-database)

+1  A: 

That query does not look like an Access query. Have you tried:

"INSERT INTO [users] ([name], [password]) VALUES ('asd', 'asd')"

In Access, table and field names do not use a back-quote, however, reserved words must be enclosed in square brackets.

Remou
Well.. that's the result of years of MySQL...
ApoY2k