2010-01-13 51 views
0

我需要獲取Visual Fox Pro數據庫中的表的列表。 (7.0)這是我在做什麼....但它不工作,或者說我這樣做是正確...檢索FoxPro 7.0數據庫架構

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) 
{} 

回答

6

我最近寫了一個代碼生成應用LINQ to VFP一個獲取架構信息。這是我如何得到模式。

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(); 
} 
+0

這太好了!謝謝湯姆! – OllieDoodle 2010-01-15 13:37:33