Hi how do you loop through all the tables in a database and then for all the rows within the table (sub loop)
So far i've got (not sure how much is right):
SqlConnection db = new SqlConnection(_connectionString);
string[] restrictions = new string[2] {"DatabaseName", null};
db.Open();
DataTable tables = db.GetSchema("Tables", restrictions);
db.Close();
for (int i = 0; i <= tables.Rows.Count; i++) {
Response.Write(tables.Rows["table"]);
}
I understand this is the way to go in asp.net 2.0 but i can't see how to get the tablename from the row in the datatable collection. I then need to do a sub loop to loop through the columns within that table.
Really appreciate it if someone could help.
Thanks
So far i've got (not sure how much is right):
SqlConnection db = new SqlConnection(_connectionString);
string[] restrictions = new string[2] {"DatabaseName", null};
db.Open();
DataTable tables = db.GetSchema("Tables", restrictions);
db.Close();
for (int i = 0; i <= tables.Rows.Count; i++) {
Response.Write(tables.Rows["table"]);
}
I understand this is the way to go in asp.net 2.0 but i can't see how to get the tablename from the row in the datatable collection. I then need to do a sub loop to loop through the columns within that table.
Really appreciate it if someone could help.
Thanks