Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2271
  • Last Modified:

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

I get error 'Record(s) cannot be read; no read permission on 'msysobjects' 'on the line given below.. any ideas how to resolve this error


Dim TableName(100)
Dim DatabasePath(100)
Dim NO_of_Records

Dim conn
Dim rec
Dim j

j = 1

Set conn = New ADODB.Connection
Set rec = New ADODB.Recordset
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Program Files\AiyshaTest\AiyshaTest.mdb;Persist Security Info=False"
esql = "SELECT Name, Database, Connect FROM msysobjects WHERE (Type=1 Or Type=4 Or Type=6) And Name Not Like ""MSys*"" ORDER BY Name"
MsgBox esql
rec.Open (esql), conn, adOpenStatic, adLockReadOnly
If rec.RecordCount > 0 Then
rec.MoveFirst
Do Until rec.EOF
TableName(j) = rec.Fields(0).Value
DatabasePath(j) = rec.Fields(1).Value
NO_of_Records(j) = rec.Fields(2).Value
rec.MoveNext
j = j + 1
Loop
End If
conn.Close
Set conn = Nothing




End Sub
0
Aiysha
Asked:
Aiysha
1 Solution
 
bruintjeCommented:
Hi Aiysha,

that table is hidden and used by Access itself you can use

rec = conn.OpenSchema(adSchemaTables)
While Not adors.EOF
    Debug.Print rec.Fields(0) ' DB
    Debug.Print rec.Fields(1) ' Owner
    Debug.Print rec.Fields(2) ' TableName
    Debug.Print rec.Fields(3) ' Type
    rec.MoveNext
Wend

i tried it here on a SQL Server so not sure if the fields returned are the same

hope this helps a bit
bruintje
0
 
AiyshaAuthor Commented:
I changed the method to DAO..
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now