ACCESS 只获取用户所有表,不包含系统表
在google上搜索了一下好像只有获取ACCESS下的所有表的方法,
我的需求是只要获得用户建的表怎么办列
public override List<string> GetAllTable()
{
List<string> list = new List<string>();
using (System.Data.OleDb.OleDbConnection conn = new System.Data.OleDb.OleDbConnection(dbo.connectionString))
{
if (conn.State == ConnectionState.Closed) conn.Open();
System.Data.DataTable table = conn.GetOleDbSchemaTable(System.Data.OleDb.OleDbSchemaGuid.Tables, new object[] { null, null, null, "TABLE" });
foreach (System.Data.DataRow drow in table.Rows)
{
//string tableType = drow["TABLE_TYPE"].ToString();
//if (tableType.ToUpper()=="TABLE")
//{
// list.Add(drow["TABLE_NAME"].ToString());
//}
list.Add(drow["TABLE_NAME"].ToString());
}
}
return list;
}
{
List<string> list = new List<string>();
using (System.Data.OleDb.OleDbConnection conn = new System.Data.OleDb.OleDbConnection(dbo.connectionString))
{
if (conn.State == ConnectionState.Closed) conn.Open();
System.Data.DataTable table = conn.GetOleDbSchemaTable(System.Data.OleDb.OleDbSchemaGuid.Tables, new object[] { null, null, null, "TABLE" });
foreach (System.Data.DataRow drow in table.Rows)
{
//string tableType = drow["TABLE_TYPE"].ToString();
//if (tableType.ToUpper()=="TABLE")
//{
// list.Add(drow["TABLE_NAME"].ToString());
//}
list.Add(drow["TABLE_NAME"].ToString());
}
}
return list;
}
参考:http://support.microsoft.com/kb/309681/zh-cn
发现有一个“TABLE_TYPE”存放表类型 可以使用