2

I'm trying to run the following query against an Access 2007 database in C#:

OleDbCommand command = new OleDbCommand();
command.Connection = connect;
command.CommandText = "SELECT * FROM MSysQueries";
OleDbDataReader reader = command.ExecuteReader();

And I get the error:

Record(s) cannot be read; no read permission on 'MSysQueries'.

Is it possible to do this? If so how? I am under the impression it is possible to do this but I'm not completely sure.

3
  • There is a similar question here. Does its answer help? Commented May 13, 2014 at 11:16
  • It is the same problem but I cant seem to get that solution to work. Commented May 14, 2014 at 14:43
  • Did you follow the instructions here to execute GRANT SELECT ON MSysQueries TO Admin? I just tried it and it worked for me. Commented May 14, 2014 at 15:31

2 Answers 2

6

As mentioned in the similar question here, to get around the

Record(s) cannot be read; no read permission on 'MSysQueries'.

error you need to GRANT SELECT privileges to the default user "Admin" with the command

GRANT SELECT ON MSysQueries TO Admin

You can execute that SQL statement from a .NET OleDbConnection, but in order to do so you need to specify the location of the default Workgroup Information File (System.mdw) in your connection string like this:

myConnectionString =
        @"Provider=Microsoft.ACE.OLEDB.12.0;" +
        @"Data Source=C:\Users\Public\Database1.accdb;" +
        @"Jet OLEDB:System database=C:\Users\Gord\AppData\Roaming\Microsoft\Access\System.mdw;";

That path to the .mdw file can be retrieved from the Windows registry by reading the value

Key:
HKEY_CURRENT_USER\Software\Microsoft\Office\14.0\Access\Access Connectivity Engine\Engines

Value:
SystemDB

(The value 14.0 in the above key is for Access 2010. Other versions of Access will have different values.)

Sign up to request clarification or add additional context in comments.

3 Comments

I knew this was the gist of the process from the other question but for the life of me I could not follow the other answers. This was very easy to follow and concise thank you.
I agree, good answer. Access 2007 is ...\Office\12.0\Access\.... I think Access 2003 is 8.0
Thank you Gord! I wish I would have seen this sooner, would have saved me an hour of googling "Cannot open the Microsoft Access database engine workgroup information file".
0

You can give access to you doing this in the Access 2007:

Tools Menu -> Security -> User and Group Permissions. Give 'Read Data' permission to the Admin user on MSysObjects table.

But you have to be sure that the MSysObjects isn't locked in purpose for security reasons.

2 Comments

I'm actually in Access 2010 and I cant find a Tools menu?
The Tools menu seems to be visible only for .mdb files. See similar question referenced in another answer. (link)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.