To check if a table exists, you can extend the DbConnection as follows:
public static class DbConnectionExtensions { public static bool TableExists(this DbConnection conn, string table) { conn.open(); var exists = conn.GetSchema("Tables", new string[4] { null, null, table, "TABLE" }).Rows.Count > 0; conn.close(); return exists; } }
You can then call TableExists in any derived class, such as OleDbConnection, SQLiteConnection, or SqlConnection.
csname1910
source share