在网络文件夹Access数据库无法通过ASP.NET读取 [英] Access DB in network folder cannot be read by ASP.NET

查看:166
本文介绍了在网络文件夹Access数据库无法通过ASP.NET读取的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个需要一些数据推送到使用Access 2003数据库后端的旧程序的ASP.NET页面。我有我的连接字符串都设立了这样做的(成功到数据库的本地副本),但是当我尝试从它的网络共享位置数据库中读取,我得到以下错误:


  

条记录无法读取;没有阅读tblDevice的许可。


有没有密码或数据库上的任何安全性,所以我pretty肯定这是与网络相关。我不知道的任何方式,包括与连接字符串网络登录/密码。我会假设这将需要增加一些用户的文件夹。但是,我不知道哪些用户需要权限到该文件夹​​,它的工作(包括从Visual Studio和IIS)。没有人有经验,这种类型的错误或知道什么是用户需要给予权限的文件夹?


我的code,以供参考:

使用连接字符串

 连接Provider = Microsoft.Jet.OLEDB.4.0;数据源= \\\\ srv.local \\ SHAREDOCS \\ data.mdb中;
    用户ID =管理员;密码=;

选择code

公共静态数据表GetDevices(字符串SERIALNUM)
{
    VAR康恩=新的OleDbConnection();
    VAR建设者=新OleDbConnectionStringBuilder();
    。builder.ConnectionString = ConfigurationManager.ConnectionStrings [发展]的ToString();
    康恩= builder.ConnectionString;    VAR的SqlString =SELECT的DeviceID,SN FROM tblDevice WHERE活动= True和SN = @ SERIALNUM ORDER BY SN,的DeviceID;    使用(VAR CMD =新的OleDbCommand(的SqlString,康涅狄格州))
    {
        cmd.Parameters.AddWithValue(@ SERIALNUM,SERIALNUM);
        变种DS =新的DataSet();
        VAR DA =新OleDbDataAdapter的(CMD);        da.Fill(DS);        返回ds.Tables [0];
    }
}


解决方案

终于想通了这一点,这是没有在附近我的预期。对于一些奇怪的原因,该数据库对各种表格中随机权限的差异。 (有些人完全访问权限,有的没有,有的混合...没有从我了解计划的运作方式情由。)要进入的权限,我不得不去这里的(Access 2010中的一个,但2003 MDB文件)的:

文件 - >信息 - >用户和权限 - >用户和组权限...

这presented我以下选项:

我所要做的就是检查每个对象的相应权限,现在,它的工作原理。

I have an ASP.NET page that needs to push some data to an older program that uses an Access 2003 database for a backend. I have my connection strings all set up to do this (successful to a local copy of the DB) but when I try to read from the database on its network share location, I get the following error:

Record(s) cannot be read; no read permission on 'tblDevice'.

There are no passwords or any security on the database, so I'm pretty sure this is network related. I'm not aware of any way to include a network login/password with the connection string. I would assume it's going to require adding a certain user to the folder. However, I'm not sure what user needs permission to that folder for it to work (both from Visual Studio and from IIS). Anyone had experience with this type of error or know what "users" need to be given permission to the folder?


My code for reference:

Access connection string

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

Selection Code

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];
    }
}

解决方案

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:

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

这篇关于在网络文件夹Access数据库无法通过ASP.NET读取的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆