[英]Error DBF file reader in C#
錯誤:查詢中的語法錯誤。 不完整的查詢條款。 請幫我。
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();
錯誤:查詢中的語法錯誤。 不完整的查詢條款。
嘗試這個:
("Select * From " + Path.GetFileNameWithoutExtension(fi.Name) , dBaseConnection)
沒有引號'路徑..'。
希望能幫助到你。
我建議使用VfpOleDb提供程序 。 以下是使用該提供程序的連接字符串:
ConnectionString = "Provider=VfpOleDb;Data Source=" + fi.DirectoryName;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.