1.11M Members

Connect to Access DB in Read Only mode

 
0
 

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

 
0
 

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.

 
0
 

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.

 
0
 

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!

 
0
 

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.

 
0
 

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.

Question Answered as of 1 Year Ago by Ancient Dragon, G_Waddell, azareth and 1 other
 
0
 

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

 
0
 

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

You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article