[英]Accessing a password protected MS access database in C# issue
I am trying to connect a password protected database in C# using DAO. 我正在尝试使用DAO在C#中连接受密码保护的数据库。 The code I have previously worked correctly with an unprotected database.
我以前使用不受保护的数据库正确编写的代码。 Now when trying to connect to the database with adding a default password it is not working.
现在,当尝试通过添加默认密码连接到数据库时,它无法正常工作。
var dbe = new DBEngine();
dbe.DefaultPassword = "abc123";
Database db = dbe.OpenDatabase(@"C:\Users\x339\Documents\Test.accdb");
I get the error: 'Cannot start your application. 我收到错误:'无法启动您的应用程序。 The workgroup information file is missing or opened exclusively by another user.'
工作组信息文件丢失或由其他用户独占打开。 I'm not really sure where I'm going wrong here.
我不确定我在哪里出错了。 Any help would be appreciated.
任何帮助,将不胜感激。
Well I wouldn't advise using DAO anymore, but if you must, use this code: 好吧,我不建议再使用DAO,但如果必须,请使用以下代码:
var dbe = new DBEngine();
var databaseFile = @"C:\Users\x339\Documents\Test.accdb";
var password = "abc123";
Database db = dbe.OpenDatabase(databaseFile, False, False, string.Format("MS Access;PWD={0}", password));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.