F.P
F.P

Reputation: 17831

OleDB not saved to database file

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: Inserting not committed to database)

Upvotes: 0

Views: 864

Answers (1)

Fionnuala
Fionnuala

Reputation: 91376

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.

Upvotes: 1

Related Questions