Domanda

Ho bisogno di ottenere un elenco di tabelle di un database Visual FoxPro. (7.0) Questo è quello che sto facendo .... ma non funziona o non sto facendo bene ...

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)
{}
È stato utile?

Soluzione

ho scritto recentemente una domanda di generazione di codice LINQ to VFP che ottiene le informazioni sullo schema. Ecco come ho ottenuto lo 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();
}
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top