I want to access some data in an Access MDB but I want to make sure that nothing can be accidentally altered.

I have tried:

        conn = New OleDbConnection(Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Test.MDB;Mode=adModeRead;")

I've also used

        conn = New OleDbConnection(Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Test.MDB;Mode=Read;")

I then run a quick UPDATE WHERE query and it still alters the data.

Any ideas thanks.

Pedro

I want to make sure that nothing can be accidentally altered.

How do you "accidentally" alter something in a program? If your program alters the data it's on purpose, not by accident. Want read-only? Just make sure your program doesn't attempt to alter the data.

I then run a quick UPDATE WHERE query and it still alters the data.

isnt't that the purpose of UPDATE?, to alter the data in the database.

I think he is running the UPDATE to test if he has opened Access in Read Only mode.

As Ancient Dragon says, the data will only be altered if you run an UPDATE, INSERT or DELETE query so don't!

I believe that the OP's reasoning may be valid if another application is accessing the DB as well. If both tried to grab total access at the same time, there may be a conflict.

Assuming that you made a typo on the forum (missing opening quote) with the connection string, the second version (Mode=Read;) should prevent you from executing insert/update commands. And yes, I have verified that it blocks writing; it throws an invalid update command when executing.

But that won't prevent other programs from updating the data. The database server locks tables when doing updates, there is nothing you need to put in your code to do that.

Thanks, I just wanted to be sure, I was paranoid about modifying a table I really do NOT want to modify!

Tables don't get modified by accident, you have to intentially do it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.