得到Access数据库中的所有表名
/// <summary>
/// 返回Mdb数据库中所有表表名
/// </summary>
public string[] GetShemaTableName(string database_path, string database_password)
{
try
{
//获取数据表
OleDbConnection conn = new OleDbConnection();
string[] strTable = new string[n];
int m = shemaTable.Columns.IndexOf("TABLE_NAME");
for (int i = 0; i < n; i++)
{
DataRow m_DataRow = shemaTable.Rows[i];
strTable[i] = m_DataRow.ItemArray.GetValue(m).ToString();
}
return strTable;
}
catch (OleDbException ex)
{
MessageBox.Show("指定的限制集无效:\n" + ex.Message);
return null;
}
finally
{
conn.Close();
conn.Dispose();
}
}
/// 返回Mdb数据库中所有表表名
/// </summary>
public string[] GetShemaTableName(string database_path, string database_password)
{
try
{
//获取数据表
OleDbConnection conn = new OleDbConnection();
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:DataBase Password='" +
database_password + "Data Source=" + database_path;
conn.Open();
DataTable shemaTable = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables,
new object[] { null, null, null, "TABLE" });
string[] strTable = new string[n];
int m = shemaTable.Columns.IndexOf("TABLE_NAME");
for (int i = 0; i < n; i++)
{
DataRow m_DataRow = shemaTable.Rows[i];
strTable[i] = m_DataRow.ItemArray.GetValue(m).ToString();
}
return strTable;
}
catch (OleDbException ex)
{
MessageBox.Show("指定的限制集无效:\n" + ex.Message);
return null;
}
finally
{
conn.Close();
conn.Dispose();
}
}