简体   繁体   中英

How do I access an Access database protected by a username/password in Access workgroups via Jet?

I found this page which suggested adding the "Jet OLEDB:System Database" item to my connection string, and then providing a username and password parameter to Open . Unfortuanately, it seems the .NET OleDb classes don't seem to have this... I tried the following code just incase:

testConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + mdbFile + 
    ";Jet OLEDB:System Database=" + Path.GetDirectoryName(mdbFile) + "\\system.mdw;" + 
    "Jet OLEDB:System Username=***;Jet OLEDB:System Password=***");

But this just seems to hang for a long time before throwing a "Could not find installable ISAM" DbException .

Does anyone have any ideas?

EDIT: I tried using the following connection string, which stopped the exception, but didn't let me access any tables, like what happens when I open Access without the workgroup setup properly.

"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + mdbFile +
";Jet OLEDB:System Database=" + Path.GetDirectoryName(mdbFile) + "\\system.mdw;" +
"User ID=***;Password=***";

I feel like an idiot now, but scrolling up a bit on that page accidentally, I noticed some of the connection strings had a "User ID" and "Password" parameters. Changing the connection string to use these instead of trying to pass them to "Jet OLEDB:*" fixed the issue.

ie, my final connection string was:

"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + mdbFile +
";Jet OLEDB:System Database=" + Path.GetDirectoryName(mdbFile) + "\\system.mdw;" +
"User ID=***;Password=***";

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM