List GetTablesName(string DatabaseName)
{
string connectionString = GetDatabaseConnectionString(DatabaseName);
DataTable tables = new DataTable();
using (SqlConnection connection = new SqlConnection(connectionString))
{
SqlCommand command = connection.CreateCommand();
command.CommandText = "select table_name as Name from INFORMATION_SCHEMA.Tables where TABLE_TYPE = 'BASE TABLE'";
connection.Open();
tables.Load(command.ExecuteReader(CommandBehavior.CloseConnection));
}
List list = new List();
foreach (DataRow row in tables.Rows)
{
list.Add(row[0].ToString());
}
return list;
}
List GetDatabasesName()
{
DataTable tables = new DataTable();
using (SqlConnection connection = new SqlConnection(connectionString))
{
SqlCommand command = connection.CreateCommand();
command.CommandText = "select name from master..sysdatabases";
connection.Open();
tables.Load(command.ExecuteReader(CommandBehavior.CloseConnection));
}
List list = new List();
foreach (DataRow row in tables.Rows)
{
list.Add(row[0].ToString());
}
// We can not visit the system databases