如何获取Access中所有表

 public List<string> GetTables()
 {
            List<string> Tables = new List<string>();
            using (OleDbConnection Con = new OleDbConnection(StrCon))
            {
                if (Con.State == ConnectionState.Closed)
                {
                    Con.Open();
                }
                DataTable schemaTable = Con.GetOleDbSchemaTable(OleDbSchemaGuid.Tables,new object[] { null, null, null, "TABLE" });
                foreach (DataRow DR in schemaTable.Rows)
                {
                    Tables.Add(DR["TABLE_NAME"].ToString());
                }

            }
            return Tables;

}

 

Con连接对象 经测试 正确!

阅读更多
个人分类: C#基础
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭
关闭