简体   繁体   English

mdb文件oledbconnection引发“ Microsoft Access数据库引擎无法打开或写入文件…”

[英]mdb file oledbconnection throws “The Microsoft Access database engine cannot open or write to the file …”

I'm writing a .Net Web Api that tries to read a .mdb file from a shared drive. 我正在编写一个.Net Web Api,尝试从共享驱动器读取.mdb文件。 But whenever I try to open the connection it gives me a 但是每当我尝试打开连接时,它都会给我一个

The Microsoft Access database engine cannot open or write to the file '\\myshareddrive\\thedatabase.mdb'. Microsoft Access数据库引擎无法打开或写入文件'\\ myshareddrive \\ thedatabase.mdb'。 It is already opened exclusively by another user, or you need permission to view and write its data. 它已经由另一个用户专门打开,或者您需要权限才能查看和写入其数据。

I've already changed my permissions on the folder and the file that involves the NETWORK SERVICE account to have modify access. 我已经更改了对文件夹和涉及NETWORK SERVICE帐户的文件的权限,以具有修改访问权限。 I also messed with the IIS to "Connect as" a user that has admin rights on the shared drive. 我还搞砸了IIS,以“连接为”对共享驱动器具有管理员权限的用户。 And yes the file is closed. 是的,文件已关闭。 Not sure where to go now. 不确定现在要去哪里。 Any advice is appreciated. 任何建议表示赞赏。

I looked at this solution: 我看着这个解决方案:

http://www.aspdotnet-suresh.com/2013/01/c-microsoft-office-access-database.html http://www.aspdotnet-suresh.com/2013/01/c-microsoft-office-access-database.html

Here's my code: 这是我的代码:

var databaseStringthatincludespath = "\\myshareddrive\thedatabase.mdb"
var connString = @"Provider=Microsoft.ACE.OLEDB.12.0;Persist Security Info=False;Data Source=" + databaseStringthatincludespath;

try
{
    OleDbConnection Myconnection = new OleDbConnection(connString);
    Myconnection.Open();
    Myconnection.Close();
    return "Yo test return!";
}
catch (Exception ex)
{
    var error = ((ex.InnerException != null) ? ex.InnerException.Message : " ") + " -- " + ex.Message;
    return error;
}

Finally figured it out. 终于想通了。 Basically you need to make sure the "Authentication" of the app on your IIS to enable impersonation (at least this is the route I took). 基本上,您需要确保IIS上应用程序的“身份验证”以启用模拟功能(至少这是我采用的方法)。 And make sure that the accoutn is recognized on the server where the path lies so that when the app gets executed as the impersonated account there won't be any issues. 并确保在路径所在的服务器上识别出accoutn,以便当应用程序作为模拟帐户执行时不会有任何问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Microsoft Office Access 数据库引擎无法打开或写入文件 - The Microsoft Office Access database engine cannot open or write to the file Microsoft Office Access 数据库引擎无法打开或写入文件 '' - The Microsoft Office Access database engine cannot open or write to the file '' Microsoft Access 数据库引擎无法打开或写入 windows 服务 c# 中的文件 - The Microsoft Access database engine cannot open or write to the file in windows service c# Microsoft jet 数据库引擎无法打开文件。''。 已被其他用户独占打开,或者您需要权限 - Microsoft jet database engine cannot open the file.''. It is already opened exclusively by another user, or you need permission Microsoft Access错误找不到.mdb,但数据库为.accdb - Microsoft Access error cannot find .mdb but database is .accdb 打开与MS Access 2007文件的连接时出错:无法打开MS Office Access数据库引擎工作组信息文件 - Error while opening a connection to MS Access 2007 file: Cannot open the MS Office Access database engine workgroup information file Microsoft Jet数据库引擎无法打开文件“。它已经由另一个用户独占打开,或者您需要获得查看其数据的权限” - The Microsoft Jet database engine cannot open the file ''.It is already opened exclusively by another user, or you need permission to view its data" 如何具有Microsoft Access驱动程序(.mdb)文件的相对路径 - How to have relative path for Microsoft Access Driver(.mdb) file 无法使用SQL(OLEDB)C#写入Microsoft Access文件 - Cannot write to a Microsoft Access file using SQL (OLEDB) C# 新建 C# 项目无法打开 ACCDB microsoft 数据库文件 - New C# project cannot open ACCDB microsoft database file
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM