I have a database in sql server which is having few tables in it.
I need to populate a listbox which contains a list of tables names from the database which contains a specified column name say 'special' .
i have tried something like..
using (SqlConnection connection = new SqlConnection(connectionString))
{
connection.Open();
List<string> tables = new List<string>();
DataTable dt = connection.GetSchema("Tables");
foreach (DataRow row in dt.Rows)
{
string tablename = (string)row[2];
tables.Add(tablename);
}
listbox1.ItemsSource = tables;
connection.Close();
}
but it is showing all the tables present in the database..
but i want only those table which have a specific columns in a list...
Kindly suggest me the way ... :)