我正在尝试运行以下代码来访问文件夹中的 DBF 文件。如果是 RF10.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
}
问题是执行查询时会出现以下错误:
Microsoft Jet 数据库引擎找不到对象“RF10.DBF”。确保对象存在并且正确拼写其名称和路径名。
但是,存在一个名为 RF10.dbf 的文件。我哪里错了?