1

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;
Baigoo
  • 31
  • 5

4 Answers4

0

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?

DRapp
  • 47,638
  • 12
  • 72
  • 142
0

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.

Tamar E. Granor
  • 3,817
  • 1
  • 21
  • 29
0

This is an old post, but I lately had the 'opportunity' to work with such a system. If you want to use the DB normally, and can't find PhDBase anymore, then use this method:

1.Set the run directory for applications to where your DBC/DBF's are:

SET DEFAULT TO "C:\your path"
  1. Create a phd.prg file in that same directory with the contents:

    LPARAMETERS param1, param2, param3, param4, param5, param6, param7, param8, param9, param10, param11, param12, param13, param14, param15, param16, param17, param18,param19,param20

    RETURN .T.

and your tables will open normally again.

Robert Achmann
  • 1,986
  • 3
  • 40
  • 66
-1

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.

Baigoo
  • 31
  • 5