Get all tables and all columns from a odbc database
The column schema will return all tables
cn.GetOleDbSchemaTable(OleDbSchemaGuid.Columns,
new Object[] { null, null, null, null });
Or for a single table
cn.GetOleDbSchemaTable(OleDbSchemaGuid.Columns,
new Object[] { null, null, "table1", null });
Similarly,
columns = cn.GetSchema("Columns");
Returns all columns in all tables.
More info: Schema Restrictions
Edit re comments
string cs = @"Driver={Microsoft Text Driver (*.txt; *.csv)};DBQ=z:\docs;";
OdbcConnection cn = new OdbcConnection(cs);
cn.Open();
DataTable tables = cn.GetSchema("Tables");
DataTable columns = cn.GetSchema("Columns");
foreach (DataRow row in columns.Rows)
{
Console.WriteLine(row["COLUMN_NAME"].ToString());
Console.WriteLine(row["TABLE_NAME"].ToString());
}
Console.Read();