我試圖運行以下代碼來訪問文件夾中的DBF文件。如果RF10.dbf文件的名稱:執行查詢時在給定路徑中找不到DBF文件
foxpro = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\Documents and Settings\\xxxxxx\\xxxxx\\xxxxx\\;Extended Properties=dBASE IV;User ID=ADMIN;Password=;");
try
{
foxpro.Open();
label4.Text = "Connected";
}
catch (OleDbException oex)
{
label4.Text = "Connection Failed";
// connection error
}
並執行以下查詢:
OleDbCommand fpcmd = new OleDbCommand();
fpcmd.Connection = foxpro;
fpcmd.CommandText = "SELECT * FROM RF10.DBF WHERE SRNO='RDDFT000108'";
fpcmd.CommandType = CommandType.Text;
fpcmd.CommandTimeout = 300;
try
{
acompressor = (String)fpcmd.ExecuteScalar();
// SqlDataAdapter da = new SqlDataAdapter(cmd1);
//DataSet ds = new DataSet();
// da.Fill(ds);
if (acompressor == null)
acompressor = "";
if (acompressor.Equals(compressor))
{
MessageBox.Show("Serial number and compressor number is a correct match.");
textBox1.Text = "";
textBox2.Text = "";
}
else
{
MessageBox.Show("Serial number and compressor number DO NOT match.");
textBox1.Text = "";
textBox2.Text = "";
}
}
catch (OleDbException oex)
{
Console.Write(fpcmd.CommandText);
Console.Write(oex.Message);
// command related or other exception
}
在執行查詢它提供了以下錯誤的問題是:
The Microsoft Jet database engine could not find the object 'RF10.DBF'. Make sure the object exists and that you spell its name and the path name correctly.
但是,有一個名爲RF10.dbf的文件。我哪裏錯了?
只讀?權限? – Steve
我使用dbf查看器瀏覽了該文件。我把它放在本地驅動器中。 – Salik