tags:

views:

142

answers:

1

I need to obtain a list of tables in a Visual Fox Pro database. (7.0) This is what I'm doing.... but it's not working or I'm not doing it right...

DataFactory dataFactory = new DataFactory();

dataFactory.CreateOldStarbaseConnection(); dataFactory.OpenOldStarbaseConnection(); OleDbConnection oldStarbaseConnection = dataFactory.OldStarbaseConnection;

object[] arrRestrict = new object[] { null, null, "NewStarbase", null };

// Get the tables in the new Database DataTable tblDbSchema = newStarbaseConnection.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, arrRestrict);

// for each table in the new database foreach (DataRow myDataRow in tblDbSchema.Rows) {}

+1  A: 

I recently wrote a code generation application for LINQ to VFP that gets the schema information. Here is how I got the schema.

using (OleDbConnection conn = new OleDbConnection(connectionString)) {
    conn.Open();
    DataTable tables = conn.GetSchema("Tables");
    DataTable columns = conn.GetSchema("Columns");
    DataTable dt = conn.GetSchema("Indexes");
    conn.Close();
}
Tom Brothers
This is great! Thanks Tom!!!
OllieDoodle