no read permission on 'MSysObjects'

可紊 提交于 2019-12-19 11:05:52

问题


I want to use MS Access in my project. I try to integrate with this code.

rs = st.executeQuery("SELECT name FROM MSysObjects where database <> ''");

By using this I try to get all the table names from MSysObjects. But I get an error:

java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Record(s) cannot be read; no read permission on 'MSysObjects'.

Please help me resolve this error.


回答1:


Give the Admin user read (SELECT) permission on MSysObjects.

In an Access session, open the Immediate window (Ctrl+g), construct a DDL GRANT statement and execute it from CurrentProject.Connection

strDdl = "GRANT SELECT ON MSysObjects TO Admin;"
CurrentProject.Connection.Execute strDdl

Note that statement must be executed from ADO. It should work as written because CurrentProject.Connection is an ADO object. However it will fail if attempted with a DAO Execute method such as CurrentDb.Execute or when run from the Access query designer.




回答2:


To connect with MS Access with read permission follow the following steps:

Open MS access 1. click "Office Button" => access option => trust center => trust center settings => Macro settings => Enable macros => Ok

  1. From your access file Press ctrl+g in that create a macro by pressing run symbol. create a macro in any name.

Inside that : paste these lines

strDdl = "GRANT SELECT ON MSysObjects TO Admin;" CurrentProject.Connection.Execute strDdl

save this... and run your macro. Finnaly you had granted select permission on "MySysObject".



来源:https://stackoverflow.com/questions/19971082/no-read-permission-on-msysobjects

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!