Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

No read access for mdb using OleDbConnection 1

Status
Not open for further replies.

rickinger

Programmer
Feb 11, 2004
20
NL
Hi guys,

I am trying to read out some tables of a regular XP access mdb but I keep getting an error message that I have no read privileges.

string strDSN = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + strDatabaseFile;
string strSQL = "SELECT Name FROM MSysObjects WHERE Type = 1;";
OleDbConnection myConn = new OleDbConnection(strDSN);
OleDbCommand myCmd = new OleDbCommand( strSQL, myConn );
OleDbDataReader datareader = null;
try
{
myConn.Open();
datareader = myCmd.ExecuteReader(CommandBehavior.CloseConnection);
while (datareader.Read() )
{
string strTest = (string) datareader["Name"];
MessageBox.Show(strTest,"hi", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
}
catch (Exception ee)
{
MessageBox.Show("Sorry, I was not able to read from " + strDatabaseFile + ":\n\n" + ee.Message, "An error occured", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
finally
{
myConn.Close();
}

Am I missing something here?
 
Hm, found out something... access on regular table works, but not on that MSys-table...
Anybody knows how this can be done?
 
well in Access 9X version you would go to

1. Tools -> Security -> User and Group Permissions
2. Select object type "Tables" (combo box)
3. Scroll the window (Object Name) above and select MSysObjects or any other table you need to access.
4. Check the read data box
5. click OK


Scott
Programmer Analyst
<{{><
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top