gpt4 book ai didi

c# - 如何连接到dbf数据库

转载 作者:搜寻专家 更新时间:2023-10-30 19:56:13 25 4
gpt4 key购买 nike

我尝试使用 C# 连接到 DBF 数据库(我尝试了 3 种连接类型)

string connectionString = @"Driver={Microsoft dBASE Driver (*.dbf)};DriverID=277;Dbq=c:\employees.dbf;";
string connectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\employees.dbf;Extended Properties=dBASE IV;";
string connectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\employees.dbf;Extended Properties=dBASE IV;User ID=Admin;Password=;";

using (OdbcConnection connection = new OdbcConnection(connectionString))
{
connection.Open();
}

我得到了错误

错误1:

ERROR [HY024] [Microsoft][ODBC dBase Driver] '(unknown)' is not a valid path. Make sure that the path name is spelled correctly and that you are connected to the server on which the file resides.
ERROR [IM006] [Microsoft][ODBC Driver Manager] Driver's SQLSetConnectAttr failed
ERROR [HY024] [Microsoft][ODBC dBase Driver] '(unknown)' is not a valid path. Make sure that the path name is spelled correctly and that you are connected to the server on which the file resides.

或错误2:

ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

可能是什么问题?

提前致谢

最佳答案

Dim Conn As New OLEDBConnection  
Conn.ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\folder;Extended Properties=dBASE IV;User ID=Admin;Password=;"

要从数据库表中进行选择,您必须执行以下操作(例如):

"SELECT * FROM tblCustomers.DBF"

(注意表名后面的.DBF)

关于c# - 如何连接到dbf数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7227711/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com