0
votes

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.

2

2 Answers

3
votes

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.

1
votes

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".