如何读取从ACCESS中读取所有用户表名

  String accpath = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+AppDomain.CurrentDomain.BaseDirectory.Substring(0,AppDomain.CurrentDomain.BaseDirectory.LastIndexOf(" \\Debug\\"))+"\\test.mdb;Persist Security Info=False";//连接字符串
              OleDbConnection conn = new OleDbConnection(accpath);\\OLEDB连接
            conn.Open();
            DataTable dt = conn.GetSchema("Tables");//获取ACCESS数据库中所有的表\查询\宏\窗体\模块
            for(int i=0;i<dt.Rows.Count;i++)
            {
                if(dt.Rows[i].ItemArray[3].ToString()=="TABLE")//判断是否是用户表
                Console.Writeln(dt.Rows[i].ItemArray[2].ToString());
            }

在SQL SERVER 中获取用户表的SQL语句是:
          select name from sysobjects where type='U'

你可能感兴趣的:(Access)