File 'phd.prg' does not exists

笑着哭i 提交于 2019-12-11 12:19:11

问题


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.

when i run query to select data from "test.dbf" it throws exception saying

File 'phd.prg' does not exists

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;

回答1:


Being that you are opening a table from a database container, I would check to see if the table in question has some triggers associated with it. If those triggers are looking for some external phd.prg file that is not visible in the path, that may be choking it. But you are only doing a select * from, so that should not be the issue. Double-check it anyhow. Does the name of "phd.prg" ring a bell to you? Does the database have stored procedures in it by this name reference it may be causing the problem?




回答2:


There used to be an add-on for FoxPro called PhDbase that provide quick search in memo fields and some other features. I'm pretty sure that the program that implemented it was called Phd.PRG and that hooking it up required calling that program (function) in an index tag.

First possibility is that the program is available, but in a folder you're not seeing with OLEDB. I don't know whether OLEDB can handle user-defined functions in index tags or not. But if you can find the file in another folder, you can try copying it to the same folder as the tables.

Second possibility: If this is old data and the application is no longer in use, you should be able to remove the relevant tag. My guess is that you'll need (or at least want) Visual FoxPro to do the work.

Third option, though I don't know if it'll work. You could create a dummy program with the right file name and put it in the right folder. It's a long time since I used PhdBase, so I don't remember its parameters and return value for sure, but you might try a function that accepts a string and returns the same string.

Hope something here helps.




回答3:


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;   
            }


    }

Thanks for your support.



来源:https://stackoverflow.com/questions/32901152/file-phd-prg-does-not-exists

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!