Question

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.

Was it helpful?

Solution

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.)

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top