VB.Net 如何获取Access数据库中的表名称

2024-11-20 22:19:55
推荐回答(1个)
回答1:

呵呵,刚刚做这个,就借花献佛了
///


/// 获得当前Access数据库的表
///

///
///
public ArrayList DataScoreTableName(string Source)
{
ArrayList TableName = new ArrayList();
string ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Source;
OleDbConnection conn = new OleDbConnection(ConnectionString);
conn.Open();
DataTable schemaTable = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables,new object[] { null, null, null, "TABLE"});
foreach (DataRow dr in schemaTable.Rows)
{
TableName.Add(dr["TABLE_NAME"]);

}
conn.Close();
return TableName;
}