gpt4 book ai didi

C# : Connecting to dbf file using Microsoft. ACE.OLEDB.12.0

转载 作者:行者123 更新时间:2023-11-30 20:58:55 24 4
gpt4 key购买 nike

我正在尝试使用 Microsoft.ACE.OLEDB.12.0 提供程序连接到 64 位操作系统中的 dbf 文件。

我写了

   [Test]
public void CustomDbfReader()
{
string filepath = @"K:\data";

var dataTable = new DataTable();

string connectionString =
"Provider=Microsoft.ACE.OLEDB.12.0;Extended Properties=dBASE IV;Data Source='" + filepath +"'" ;

using (var oledbConnection = new OleDbConnection(connectionString))
{
oledbConnection.Open();
string stringCommadn = string.Format(@"select * from filename.dbf");
var oleDbCommand = new OleDbCommand(stringCommadn, oledbConnection);
var oleDbDataAdapter = new OleDbDataAdapter
{
SelectCommand = oleDbCommand
};
oleDbDataAdapter.Fill(dataTable);
}
Assert.IsNotEmpty(dataTable.Rows);
}

我得到这个异常

System.Data.OleDb.OleDbException : The Microsoft Access database engine could not find the object 'CardifOrigin.dbf'. Make sure the object exists and that you spell its name and the path name correctly. If 'CardifOrigin.dbf' is not a local object, check your network connection or contact the server administrator.

我确信路径和文件名都存在。

有什么问题?

最佳答案

名称的数据库规则强制最多 10 个字符。在 Approach 中,有关较长名称的信息存储在 Microsoft 不知道的特殊索引中。

12 个字符的那个是行不通的。如果将其重命名为 8 个字符,则可以正常工作。

The Microsoft Jet database engine could not find the object filename

In Microsoft Access, when you import a dBase, FoxPro, or Paradox filethat does not follow the MS-DOS 8.3 file name format (that is, itsname before the period exceeds eight characters, or it lacks athree-character extension following the period), you may receive thefollowing error message:

The Microsoft Jet database engine could notfind the object filename. Make sure the object exists and that youspell its name and the path name correctly.

关于C# : Connecting to dbf file using Microsoft. ACE.OLEDB.12.0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15806511/

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