1

当我正在处理 windows .Net Windows 窗体应用程序时,我想知道我们可以a FoxPro OR Dbase database file在 .Net Windows 窗体应用程序中使用 DBF ( ) 吗?

我想DBF用作我的 winform .Net 应用程序的后端数据库。

如果您对此有任何想法/解决方案,请告诉我。

提前致谢。

4

4 回答 4

3

根据connectionstrings.com,有几种方法可以连接到 DBF。

只需使用正确的连接字符串,就可以了。

于 2010-12-25T11:01:08.770 回答
3

使用ODBC类访问 DBF 文件。查看connectionstrings.com以找出正确的连接字符串。它应该是以下内容:

string dbfDirectory = @"C:\the_path_to_my_dbf_file_or_files";

using (OdbcConnection conn = new OdbcConnection(@"Driver={Microsoft dBASE Driver (*.dbf)};DriverID=277;Dbq=" + dbfDirectory + ";"))
{
    conn.Open();

    using (OdbcCommand cmd = conn.CreateCommand())
    {
        cmd.CommandText = "SELECT * FROM myDbFileFromTheUpperDirectory.dbf";

        using (OdbcDataReader reader = cmd.ExecuteReader())
        {
            while (reader.Read())
            {
                // do something
            }
        }
    }
}
于 2010-12-25T11:03:34.960 回答
1

如果您有一个 OLE DB(首选)或 ODBC 驱动程序,那么是的,绝对是。

于 2010-12-25T11:00:15.647 回答
1

Additionally to the above, since .DBF files are also associated with Visual FoxPro applications, you can easily hook up with VFP's OleDB provider instead of ODBC.

于 2010-12-31T15:36:44.853 回答