Get table names in an Access .mdb database
-
Please take a good look at this and give me some clues!!! I need to list every table in the Access database. This code (which is from the .NET Framework Class Library DataTableCollection Class page on MSDN) appears to get the info that is needed, but what does the dataset coding look like for this to work?
private void GetTables(DataSet ds) { // Get Each DataTable in the DataTableCollection and print each row value. foreach (DataTable t in ds.Tables) foreach (DataRow r in t.Rows) foreach (DataColumn c in t.Columns) if (r[c] != null) Console.WriteLine(r[c]); }
Regards, Bill Antonacchio -
Please take a good look at this and give me some clues!!! I need to list every table in the Access database. This code (which is from the .NET Framework Class Library DataTableCollection Class page on MSDN) appears to get the info that is needed, but what does the dataset coding look like for this to work?
private void GetTables(DataSet ds) { // Get Each DataTable in the DataTableCollection and print each row value. foreach (DataTable t in ds.Tables) foreach (DataRow r in t.Rows) foreach (DataColumn c in t.Columns) if (r[c] != null) Console.WriteLine(r[c]); }
Regards, Bill AntonacchioHi Bill. You're going to want to use the
GetOleDbSchemaTable
method of theOleDbConnection
object to get your list of tables. This Microsoft KB document should help. http://support.microsoft.com/?id=309488[^] -
Please take a good look at this and give me some clues!!! I need to list every table in the Access database. This code (which is from the .NET Framework Class Library DataTableCollection Class page on MSDN) appears to get the info that is needed, but what does the dataset coding look like for this to work?
private void GetTables(DataSet ds) { // Get Each DataTable in the DataTableCollection and print each row value. foreach (DataTable t in ds.Tables) foreach (DataRow r in t.Rows) foreach (DataColumn c in t.Columns) if (r[c] != null) Console.WriteLine(r[c]); }
Regards, Bill AntonacchioOops - I gave you the link to the VB.NET version. Here's the C# version: http://support.microsoft.com/default.aspx?scid=kb;EN-US;309681[^]
-
Oops - I gave you the link to the VB.NET version. Here's the C# version: http://support.microsoft.com/default.aspx?scid=kb;EN-US;309681[^]