问题
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
- 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