1,105,334 Community Members

Connect to Access DB in Read Only mode

Member Avatar
pedders
Newbie Poster
12 posts since Jan 2013
Reputation Points: 7 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
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

Member Avatar
Ancient Dragon
Achieved Level 70
27,573 posts since Aug 2005
Reputation Points: 5,231 [?]
Q&As Helped to Solve: 3,028 [?]
Skill Endorsements: 115 [?]
Team Colleague
Featured
Sponsor
 
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.

Member Avatar
azareth
Posting Whiz in Training
247 posts since Apr 2012
Reputation Points: 5 [?]
Q&As Helped to Solve: 21 [?]
Skill Endorsements: 0 [?]
 
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.

Member Avatar
G_Waddell
Practically a Posting Shark
821 posts since Nov 2009
Reputation Points: 131 [?]
Q&As Helped to Solve: 137 [?]
Skill Endorsements: 13 [?]
 
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!

Member Avatar
TnTinMN
Practically a Master Poster
640 posts since Jun 2012
Reputation Points: 418 [?]
Q&As Helped to Solve: 152 [?]
Skill Endorsements: 16 [?]
 
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.

Member Avatar
Ancient Dragon
Achieved Level 70
27,573 posts since Aug 2005
Reputation Points: 5,231 [?]
Q&As Helped to Solve: 3,028 [?]
Skill Endorsements: 115 [?]
Team Colleague
Featured
Sponsor
 
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
Member Avatar
pedders
Newbie Poster
12 posts since Jan 2013
Reputation Points: 7 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

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

Member Avatar
Ancient Dragon
Achieved Level 70
27,573 posts since Aug 2005
Reputation Points: 5,231 [?]
Q&As Helped to Solve: 3,028 [?]
Skill Endorsements: 115 [?]
Team Colleague
Featured
Sponsor
 
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