We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,870 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Connect to Access DB in Read Only mode

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

6
Contributors
7
Replies
23 Hours
Discussion Span
3 Months Ago
Last Updated
9
Views
Question
Answered
pedders
Newbie Poster
10 posts since Jan 2013
Reputation Points: 7
Solved Threads: 0
Skill Endorsements: 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.

Ancient Dragon
Achieved Level 70
Team Colleague
32,123 posts since Aug 2005
Reputation Points: 5,836
Solved Threads: 2,575
Skill Endorsements: 69

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.

azareth
Posting Whiz in Training
245 posts since Apr 2012
Reputation Points: 5
Solved Threads: 18
Skill Endorsements: 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!

G_Waddell
Practically a Master Poster
619 posts since Nov 2009
Reputation Points: 107
Solved Threads: 92
Skill Endorsements: 5

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.

TnTinMN
Practically a Master Poster
640 posts since Jun 2012
Reputation Points: 418
Solved Threads: 148
Skill Endorsements: 13

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.

Ancient Dragon
Achieved Level 70
Team Colleague
32,123 posts since Aug 2005
Reputation Points: 5,836
Solved Threads: 2,575
Skill Endorsements: 69
Question Answered as of 3 Months Ago by Ancient Dragon, G_Waddell, azareth and 1 other

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

pedders
Newbie Poster
10 posts since Jan 2013
Reputation Points: 7
Solved Threads: 0
Skill Endorsements: 0

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

Ancient Dragon
Achieved Level 70
Team Colleague
32,123 posts since Aug 2005
Reputation Points: 5,836
Solved Threads: 2,575
Skill Endorsements: 69

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page rendered in 0.0921 seconds using 2.72MB