1

I've been trying to get an access tables names in c#, using:

m_cnADONewConnection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=test.mdb";
m_cnADONewConnection.Open();
DataTable userTables = m_cnADONewConnection.GetSchema("Tables");

But don't know how to show only the tables names...any help?

Soner Gönül
  • 97,193
  • 102
  • 206
  • 364
user3379482
  • 557
  • 1
  • 10
  • 21

1 Answers1

0
// Add list of table names to string list
List<string> names = new List<string>();
for (int i=0; i < userTables.Rows.Count; i++)
    names.Add(userTables.Rows[i][2].ToString());

I took this from a similar question.

Community
  • 1
  • 1
DaveH
  • 534
  • 1
  • 7
  • 17
  • Thanks for the quick response by the way. – user3379482 Apr 16 '14 at 15:00
  • I guess that's up to you. You could write them out to the console with `Console.WriteLine(userTable.Rows[i][2].ToString());` Or you could add them to a listbox or other UI element if that's what you need. – DaveH Apr 16 '14 at 15:03
  • Done...simply name[0] for example...You deserve a big green check mark! – user3379482 Apr 16 '14 at 15:06