gpt4 book ai didi

c# - C# 中的错误 DBF 文件读取器

转载 作者:行者123 更新时间:2023-11-30 18:38:44 25 4
gpt4 key购买 nike

错误:查询中的语法错误。不完整的查询子句。请帮助我。

        string db_file = null;
OpenFileDialog op = new OpenFileDialog();
op.InitialDirectory = Application.StartupPath + "\\out";
op.Filter = "DBF file|*.dbf";
if (op.ShowDialog() == DialogResult.OK)
{
db_file = op.FileName;
FileInfo fi = new FileInfo(op.FileName);

String ConnectionString;
ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + fi.DirectoryName + ";Extended Properties=dBase 5.0;Mode=Read|Write|Share Deny None;Persist Security Info=True";
System.Data.OleDb.OleDbConnection dBaseConnection;
dBaseConnection = new System.Data.OleDb.OleDbConnection(ConnectionString);
dBaseConnection.Open();
System.Data.OleDb.OleDbCommand dBaseCommand;

dBaseCommand = new System.Data.OleDb.OleDbCommand("Select * From '" + Path.GetFileNameWithoutExtension(fi.Name) + "'", dBaseConnection);
System.Data.OleDb.OleDbDataReader dBaseDataReader;
dBaseDataReader = dBaseCommand.ExecuteReader();
while (dBaseDataReader.Read())
{
MessageBox.Show("x");
}
dBaseDataReader.Close();

错误:查询中的语法错误。不完整的查询子句。

最佳答案

我建议使用 VfpOleDb provider .这是使用该提供程序的连接字符串:

ConnectionString = "Provider=VfpOleDb;Data Source=" + fi.DirectoryName;

关于c# - C# 中的错误 DBF 文件读取器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10949818/

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