女士访问:无法读取记录;没有[表格]的读取权限 [英] Ms Access: Record(s) cannot be read; no read permission on [table]
问题描述
我编写了脚本,用于下载mdb文件并阅读OLEDB提供程序提供的文件.一切正常,但如果我尝试从表中读取,则会引发异常:
i wrote script for downloading mdb files and reading them due OLEDB provider. All works fine, but if i try to read from table, it throws an exception:
访问权限:无法读取记录;没有对tblMytable的读取权限
var cmd = new OleDbCommand("SELECT * FROM tblMytable", conn);
var reader = cmd.ExecuteReader();
我直接在Ms Access中更改了用户管理员"的权限,并且它可以正常工作.但是问题是,该脚本每天至少运行两次,并下载约20个文件.因此,不可能手动更改权限.
I changed permissions directly in Ms Access for user "administrator" and it works. But the problem is, that this script musst run twice a day and it downloads about 20 files. So its impossible manually changing permissions.
是否可以通过编程方式更改表的读取权限?
非常感谢任何想法!
推荐答案
我通过使用system.mdw文件解决了此问题.我将此文件从"c:\ Users \ Administrator \ AppData \ Roaming \ Microsoft \ Access \"(在Win7中)复制到应用程序目录(App_Data),并修改了连接字符串.
I solved this by using system.mdw file. I copied this file from "c:\Users\Administrator\AppData\Roaming\Microsoft\Access\" (in Win7) to application directory (App_Data) and modified connection string.
string connectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\Database.MDB;Persist Security Info=True;Jet OLEDB:System Database=|DataDirectory|\System.MDW;
var conn = new OleDbConnection(connectionString);
如果仍然无法读取数据,我将执行Grant命令:
If still it's impossible to read data, i execute grant command:
"GRANT SELECT ON TABLE tblTable TO PUBLIC"
它有效:)
这篇关于女士访问:无法读取记录;没有[表格]的读取权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!