Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2009

    Red face Unanswered: accesing MSysObjects via C#

    Hey Guys,

    I am using C# and access 2007.

    I am trying to to figure out whether a certain table exists in the access 2007 database.

    This is the query I am using:

    SELECT MSysObjects.Name, MSysObjects.Type
    FROM MSysObjects
    WHERE (MSysObjects.Name="MyTablName") AND (MSysObjects.Type=1);

    When run from the database, it operates fine.

    However, when I run it from C#, I get the "no read permission on 'MSysObjects'' error.

    I tryied to change permissions, but could find where there are in access 2007.

    What should I do?

    p.s as I saw in other forums, I do NOT want to rewrite the code in VB or any other language. I only know C#.


  2. #2
    Join Date
    Dec 2009
    I did a quick search for the error message and found something that may help.
    It's in VB so I'll translate it for you. I also had to change it from the original a little to work.
    Here is a link to the original artical
    An Error Has Occurred - ASP.NET Forums

    Here is the code:

            public bool getTables(string tableName)
                bool tableExists = false;
                OleDbConnection conn = new OleDbConnection(conStr);
                DataTable dt = conn.GetSchema("Tables");
                foreach (DataRow row in dt.Rows)
                    if (row.ItemArray[2].ToString() == tableName)
                        tableExists = true;
                return tableExists;
    I got this to work.. Hope it helps


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts