gpt4 book ai didi

c# - 打开 dbf 文件时出错 : External table is not in expected format

转载 作者:行者123 更新时间:2023-12-02 05:11:47 25 4
gpt4 key购买 nike

我正在使用下面的代码导入 dbf 文件。

但是我得到一个错误:

'External table is not in expected format'

if (ofdDBF.ShowDialog()==DialogResult.OK) 
{
string connStr = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + ofdDBF.FileName.Substring(0, ofdDBF.FileName.LastIndexOf("\\")) + ";Extended Properties=dBASE IV;";
OleDbConnection conn = new OleDbConnection(connStr);
conn.Open();

string cmd_string = "select * from " + ofdDBF.SafeFileName.Substring(0, ofdDBF.SafeFileName.IndexOf("."));
MessageBox.Show(cmd_string);
OleDbDataAdapter da = new OleDbDataAdapter(cmd_string, conn);
DataSet ds = new DataSet();
da.Fill(ds);
dgvImport.DataSource = ds.Tables[0];
}

有什么帮助吗?

最佳答案

同样的问题(在 64 位系统上),解决方案

下载:http://download.microsoft.com/download/b/f/b/bfbfa4b8-7f91-4649-8dab-9a6476360365/VFPOLEDBSetup.msi

string connString = @"Provider=vfpoledb;Data Source=C:\Directory;Collating Sequence=machine;";
using (OleDbConnection con = new OleDbConnection(connString))
{
con.Open();

OleDbCommand command = new OleDbCommand("Select * from Table.DBF", con);
OleDbDataReader reader = command.ExecuteReader();
...
}

关于c# - 打开 dbf 文件时出错 : External table is not in expected format,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15321135/

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