Mit dieser Methode werden alle Tabellennamen einer Access Datenbank abgerufen.
// using System.Collections.Generic;
// using System.Data;
// using System.Data.OleDb;
/// <summary>
/// Gets all tables.
/// </summary>
/// <param name="connectionString">The connection string.</param>
/// <returns></returns>
private static List<string> GetAllTables(string connectionString)
{
List<string> tables = new List<string>();
OleDbConnection connection = new OleDbConnection(connectionString);
connection.Open();
DataTable dataTable = connection.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, new object[] { null, null, null, null });
for (int i = 0; i < dataTable.Rows.Count; i++)
if (dataTable.Rows[i]["TABLE_TYPE"].ToString() == "TABLE")
tables.Add(dataTable.Rows[i]["TABLE_NAME"].ToString());
connection.Close();
return tables;
}
Kommentare zum Snippet