无法启动您的应用程序 工作组信息文件不存在或被其他用户以独占方式打开

Can not start your application The workgroup information file is absent or opened exclusively by another user

我正在尝试 运行 查询位于远程服务器上的访问数据库(我的代码是用 C# 编写的)。 我使用以下代码和连接字符串:

public static string MadoneConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source= {0}; Persist Security Info = False; User ID = {1}; Password ={2};";

string ConnectionString = string.Format(Constants.MadoneConnectionString, DatabasePath, userId, password);

using (OleDbConnection cnn = new OleDbConnection(ConnectionString))
            {
                //..my code..//
                int count = 0;
                using (OleDbCommand cmd = new OleDbCommand(query, cnn))
                {
                    cnn.Open();
                    using (OleDbDataReader reader = cmd.ExecuteReader())
                    {
                        // my code //
                    }
                }
            }

当我运行代码时,我的标题有错误:

Can not start your application The workgroup information file is absent or opened exclusively by another user.

我尝试按照建议here,并添加了这个

Jet OLEDB:System Database=system.mdw;

到连接字符串,

但是我收到一条消息说登录名或密码错误。

有人遇到同样的错误吗?你是怎么解决的?

谢谢

这是由于其他人在 access 中打开数据库文件而创建了锁。由于您在应用程序中使用 using 语句,因此不应该保持连接打开,因此您的代码似乎不太可能导致锁定。在我以前的公司,当 ASP 页面尝试连接到访问数据库并且有人打开它时,这种情况经常发生。

我能想到的两种方案是:

  1. 确保数据库不能被其他人打开,通过更改文件位置或只是告诉人们不要打开。

  2. 更好的解决方案,有一个可以支持多个用户的数据库服务器。

添加

Jet OLEDB:System Database=system.mdw; 

我的连接字符串解决了这个问题。我尝试使用的登录已停用,这就是为什么会出现一条错误消息,提示登录错误。感谢大家的宝贵时间。

这也可能是由于数据库未使用密码时连接字符串中的密码引起的。