2010-01-13 78 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