3

エラー:クエリの構文エラー。不完全なクエリ句。私を助けてください。

        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();   

エラー:クエリの構文エラー。不完全なクエリ句。

4

2 に答える 2

0

これを試して:

("Select * From " + Path.GetFileNameWithoutExtension(fi.Name) , dBaseConnection)

引用符なしの「パス..」。

それが役に立てば幸い。

于 2012-06-08T13:31:59.177 に答える
0

VfpOleDbプロバイダーを使用することをお勧めします。そのプロバイダーを使用した接続文字列は次のとおりです。

ConnectionString = "Provider=VfpOleDb;Data Source=" + fi.DirectoryName;
于 2012-06-08T14:03:49.697 に答える