Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

use GetOleDbSchemaTable to get the columns of a table named "Street"

I'm trying to read the column names of a table "Streets" in an Access database by opening an OleDbConnection. I call GetOleDbSchemaTable but I can't seem to figure out how to get at my columns.

I'd like to use .NET 3.5 framework if possible.

like image 271
patrick Avatar asked Oct 28 '25 15:10

patrick


1 Answers

using (OleDbConnection connection = new OleDbConnection(connectionString))
{
    connection.Open();

    DataTable tableColumns = connection.GetOleDbSchemaTable(OleDbSchemaGuid.Columns, new object[] { null, null, "Streets", null }));
    foreach (DataRow row in tableColumns.Rows)
    {
        var columnNameColumn = row["COLUMN_NAME"];
        var dateTypeColumn = row["DATA_TYPE"];
        var ordinalPositionColumn = row["ORDINAL_POSITION"];
        ...
    }
}
like image 87
vc 74 Avatar answered Oct 30 '25 07:10

vc 74