文件"phd.prg"不存在 [英] File 'phd.prg' does not exists
问题描述
我有一个Visual Fox Pro 9数据库,我正在尝试从桌面应用程序连接它.
I have a visual fox pro 9 database, and i am trying to connect it from my desktop application.
除一张表外,我几乎可以从所有表中获取数据.
i can get data from almost all tables except one table.
当我运行查询以从"test.dbf"中选择数据时,它会抛出异常
when i run query to select data from "test.dbf" it throws exception saying
文件"phd.prg"不存在
File 'phd.prg' does not exists
我正在使用VFP OLEDB驱动程序与数据库连接.
i am using VFP OLEDB drivers to connect with database.
DataTable YourResultSet = new DataTable();
OleDbConnection yourConnectionHandler = new OleDbConnection(
"Provider=VFPOLEDB.1;Data Source=E:/TRACKONE.DBC;Exclusive=false;Nulls=false;");
yourConnectionHandler.Open();
if (yourConnectionHandler.State == ConnectionState.Open)
{
OleDbDataAdapter DA = new OleDbDataAdapter();
string mySQL = "SELECT * FROM TEST.DBF";
OleDbCommand MyQuery = new OleDbCommand(mySQL, yourConnectionHandler);
DA.SelectCommand = MyQuery;
try
{
DA.Fill(YourResultSet);
}
catch (OleDbException ex)
{
MessageBox.Show(ex.Message.ToString());
}
yourConnectionHandler.Close();
return YourResultSet;
}
else
{
MessageBox.Show("Error Opening Databse");
}
return null;
推荐答案
我终于开始工作了,看来新的oledb驱动程序存在问题,所以我现在正在使用ODBC驱动程序"Microsoft Visual FoxPro驱动程序".很难找到,但是经过大量搜索之后,我在这里找到了该驱动程序. VFODBC
I Got it working finally, it seems there was problem with new oledb driver, so i am using ODBC driver "Microsoft Visual FoxPro Driver" now. it was hard to find but after alot of search i found this driver here.VFODBC
public DataTable GetYourData2(string textquery)
{
using (OdbcConnection conn = new OdbcConnection("Driver={Microsoft Visual FoxPro Driver};SourceType=DBF;Exclusive=No;Collate=Machine;NULL=NO;DELETED=YES;BACKGROUNDFETCH=NO;SourceDB=e:/"))
{
OdbcDataAdapter ODA = new OdbcDataAdapter();
OdbcCommand ODC = new OdbcCommand(textquery, conn);
ODA.SelectCommand = ODC;
conn.Open();
ODA.Fill(YourResultSet);
return YourResultSet;
}
}
感谢您的支持.
这篇关于文件"phd.prg"不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!