当我正在处理 windows .Net Windows 窗体应用程序时,我想知道我们可以a FoxPro OR Dbase database file
在 .Net Windows 窗体应用程序中使用 DBF ( ) 吗?
我想DBF
用作我的 winform .Net 应用程序的后端数据库。
如果您对此有任何想法/解决方案,请告诉我。
提前致谢。
根据connectionstrings.com,有几种方法可以连接到 DBF。
只需使用正确的连接字符串,就可以了。
使用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
}
}
}
}
如果您有一个 OLE DB(首选)或 ODBC 驱动程序,那么是的,绝对是。
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.