Main Page | Report Page

 

  .NET DotNet Forum Index » Visual C# Forum » Access Database Schema...

Author Message
Peter...
Posted: Fri Feb 27, 2009 2:39 am
 
C# .NET 3.5

Does anyone have an example of how to get Schema of Access Database - The
Listing of all tables and fields in each table

Thank You


Peter
 
Alberto Poblacion...
Posted: Fri Feb 27, 2009 2:39 am
 
"Peter" <czupet at (no spam) nospam.nospam> wrote in message
news:%23rlNsgKmJHA.1184 at (no spam) TK2MSFTNGP04.phx.gbl...
Quote:
Does anyone have an example of how to get Schema of Access Database - The
Listing of all tables and fields in each table

To get the tables:

OleDbConnection cn = new OleDbConnection(connectionString);
...
DataTable schemaTable = cn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables,
new object[] {null, null, null, "TABLE"});
//schemaTable now contains one row for each table in the database

To get the fields:

DataTable schemaTable = cn.GetOleDbSchemaTable(OleDbSchemaGuid.Columns,
new Object[]{null, null, tableName});
//schemaTable now contains one row for each column in tableName
 
Peter...
Posted: Fri Feb 27, 2009 4:14 pm
 
Thank You!

That works!


"Alberto Poblacion" <earthling-quitaestoparacontestar at (no spam) poblacion.org> wrote
in message news:Ovz%23brKmJHA.3792 at (no spam) TK2MSFTNGP04.phx.gbl...
Quote:
"Peter" <czupet at (no spam) nospam.nospam> wrote in message
news:%23rlNsgKmJHA.1184 at (no spam) TK2MSFTNGP04.phx.gbl...
Does anyone have an example of how to get Schema of Access Database - The
Listing of all tables and fields in each table

To get the tables:

OleDbConnection cn = new OleDbConnection(connectionString);
...
DataTable schemaTable = cn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables,
new object[] {null, null, null, "TABLE"});
//schemaTable now contains one row for each table in the database

To get the fields:

DataTable schemaTable = cn.GetOleDbSchemaTable(OleDbSchemaGuid.Columns,
new Object[]{null, null, tableName});
//schemaTable now contains one row for each column in tableName


 
 
Page 1 of 1    
All times are GMT - 5 Hours
The time now is Thu Feb 11, 2016 2:09 pm