如何阅读从C#一个FoxPro 8.0数据库? [英] How do I read a Foxpro 8.0 database from c#?

查看:151
本文介绍了如何阅读从C#一个FoxPro 8.0数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要导入从FoxPro 8.0表到SQL Server。我如何读表和放大器;从FoxPro目录架构/ C#中的文件,这样我就可以创建表的SQL Server和在复制数据?

I need to import tables from foxpro 8.0 to sql server. How do I read the tables & schema from a foxpro directory/files in C# so I can create the tables in SQL Server and copy the data over?

推荐答案

您可以通过使用的的getSchema 方法上OleDb.Connection类。

You can accomplish this through the use of the GetSchema method on the OleDb.Connection class.

OleDbConnection connection = new OleDbConnection(
    "Provider=VFPOLEDB.1;Data Source=.\\Northwind\\Northwind.dbc;"
);
connection.Open();
DataTable tables = connection.GetSchema(
    System.Data.OleDb.OleDbMetaDataCollectionNames.Tables
);

foreach (System.Data.DataRow rowTables in tables.Rows)
{
    Console.Out.WriteLine(rowTables["table_name"].ToString());
    DataTable columns = connection.GetSchema(
        System.Data.OleDb.OleDbMetaDataCollectionNames.Columns, 
        new String[] { null, null, rowTables["table_name"].ToString(), null }
    );
    foreach (System.Data.DataRow rowColumns in columns.Rows)
    {
        Console.Out.WriteLine(
            rowTables["table_name"].ToString() + "." +
            rowColumns["column_name"].ToString() + " = " +
            rowColumns["data_type"].ToString()
        );
    }
}

这篇关于如何阅读从C#一个FoxPro 8.0数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆