0

我有一个 ASP.NET 页面,它需要将一些数据推送到一个使用 Access 2003 数据库作为后端的旧程序。我已经设置了所有连接字符串来执行此操作(成功到数据库的本地副本)但是当我尝试从其网络共享位置的数据库中读取时,我收到以下错误:

无法读取记录;'tblDevice' 没有读取权限。

数据库上没有密码或任何安全措施,所以我很确定这与网络有关。我不知道有什么方法可以在连接字符串中包含网络登录名/密码。我认为这将需要将某个用户添加到文件夹中。但是,我不确定哪个用户需要对该文件夹的权限才能使其工作(来自 Visual Studio 和 IIS)。任何人都有过此类错误的经验或知道需要向哪些“用户”授予对该文件夹的权限?


我的参考代码:

访问连接字符串

Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\\srv.local\SHAREDOCS\data.mdb;
    User Id=admin;Password=;

选择代码

public static DataTable GetDevices(string serialNum)
{
    var conn = new OleDbConnection();
    var builder = new OleDbConnectionStringBuilder();
    builder.ConnectionString = ConfigurationManager.ConnectionStrings["development"].ToString();
    conn = builder.ConnectionString;

    var sqlString = "SELECT DeviceID, SN FROM tblDevice WHERE Active=True AND SN=@serialNum ORDER BY SN, DeviceID; "

    using (var cmd = new OleDbCommand(sqlString, conn))
    {
        cmd.Parameters.AddWithValue("@serialNum", serialNum);
        var ds = new DataSet();
        var da = new OleDbDataAdapter(cmd);

        da.Fill(ds);

        return ds.Tables[0];
    }
}
4

2 回答 2

1

Finally figured this out, and it was no where near what I expected. For some odd reason, the database had random differences in permission on the various tables. (Some had full access, some none, some mixed... no rhyme or reason from what I know about the way the program works.) To get to the permissions, I had to go here (Access 2010 but a 2003 MDB file):

File -> Info -> Users and Permissions -> User and Group Permissions...

That presented me with the following options:

enter image description here

All I had to do was check the appropriate permissions for each object and now it works.

于 2013-03-04T19:40:47.560 回答
0

检查运行应用程序池的服务帐户是否具有对数据库的权限。如果您的服务帐户在没有权限下运行,那么您很可能会遇到这样的问题。

于 2013-03-04T17:42:59.563 回答