Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hello!

 

I am trying to get Table Name from Access database by using ADO.NET.

Here is the code that I used. After run, it appears error as "An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in system.data.dll"

 

 


Dim DataCommand As OleDbCommand
Dim DataReader As OleDbDataReader
DataCommand = New OleDbCommand
DataCommand.Connection = DataConnection
DataCommand.CommandType = CommandType.Text
DataCommand.CommandText = "SELECT * FROM MSysObjects Where Type=1 and Flags=0"
DataConnection.Open()
DataReader = DataCommand.ExecuteReader
If DataReader.HasRows Then
      MsgBox("OK, there are some tables!")
Else
      Msgbox("There is no table!")
End If
DataReader.Close()

If I change the table from MSysObjects to be other regular tables, it works fine. So, I am wondering if ADO.NET can be used to access to the system table or not. Or What I have been doing wrong? Would you please help advice?

 

Thank you very much.

Tanai

Posted
If I change the table from MSysObjects to be other regular tables' date=' it works fine. So, I am wondering if ADO.NET can be used to access to the system table or not. [/quote']

Yes you can. But you need to have read rights to access the MSysObjects table.

You need to use the right login and have the right System.mdw

 

Can you open the database using Access?

If you can't then you need to get the right System.mdw and username/password

 

HTH

/Kejpa

Posted

Dear /Kejpa,

 

Thank you very much for your advice.

 

The problem does come from the access right. I have just known that userid "admin" does not have access right to those system tables by default eventhough it can browse the system table in MS Access directly.

 

Have a nice day!

Tanai

Posted

Hi Chester,

 

The easiest, it is use MS Access to set it up. :p The hard way, I think it is to use ADOX to set the permission. However, in my point of view, if I have to use ADOX, I 'd better use ADOX to get table name and schema directly. That would be easier.

 

Cheers,

Tanai

Posted

Yeah and that brings up a good point, why not just use the get schema command to find out if you have tables, instead of trying to read the data dictionary? Just trying to learn some things here :)

 

Chester

____________________________________________

http://www.pophamcafe.com

I am starting a developers section, more tutorials than anything.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...