我试图运行以下代码来访问文件夹中的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