0

I am attempting to read a foxpro table called SCHEDULE.dbf. The data is read in PHP via data connector then piped to my webpage. This all works wonderfully, provided I rename Schedule.dbf. Any name except Schedule seems to work. When I run it named Schedule, however, I get "SQL error: [Microsoft][ODBC dBase Driver] Index file not found., SQL state S0012 in SQLExecDirect" error message. My only idea is that Schedule is a reserved word someplace, but I can't find it on any list. I am at an utter loss. Renaming the table is not really an option as it is part of a larger data entry and management system that I would rather not modify. Any suggestions?

Rich
  • 3
  • 1
  • Does `schedule.cdx` exist in the same directory? If it does, it's probably corrupted. – DaveRandom Apr 25 '12 at 13:41
  • schedule.cdx is there. Wouldn't it still throw the error though when I changed the name of Schedule to Schedul without changing the cdx's name? – Rich Apr 25 '12 at 14:00

2 Answers2

0

The error is "Index file not found" - The matching .cdx index file is not present in the same directory as the .dbf file. Make sure it is in the same directory or you can use FoxPro to remove the index from the table.

DaveB
  • 9,470
  • 4
  • 39
  • 66
  • The cdx is present and named the same. Why does it work when I change the name of the Schedule to say Schedul though? It seems to me that the cdx would still be un-found? – Rich Apr 25 '12 at 13:49
0

I can't say for dBASE (and I would use Microsoft's OleDb provider specifically for VFP if it IS Foxpro data and not dBASE). In Foxpro, the system works with paired (or even triple) files. All corresponding file names need to be renamed, such as

SCHEDULE.DBF (main data)
SCHEDULE.CDX (compound index file for all indexes for given file)
SCHEDULE.FPT (separate file if any memo/general data columns in the file)

If you try to just rename the .DBF but not the rest (.FPT is only found IF a data column is of type memo or general), then it will choke opening the file.

Additionally. If the table is part of a database container (via VFP), and you try to open it, the file has additional header information to point to the database it is bound to. If it can't find it in the database, that too could give you a misdirected error.

Database Containers in VFP have suffix values of .DBC, .DCT and .DCX.

DRapp
  • 47,638
  • 12
  • 72
  • 142
  • You raise a very valid point, I have been using the dBase ODBC. I'll give it a try with the FP OleDb! – Rich Apr 25 '12 at 15:59
  • One thing to consider is with reserved words because they are a function built into VFP there are ways around them to tell VFP you meant it as a file and not a function. For example I have a program I call go. So I can't type "go()" and I have to type "do go". If I have parameters I need to call then I need to type "do go with ". Also to call a database as a literal file add the extension on the end if it's a reserved word or even if you think it might be. – Steven Gruner May 10 '12 at 21:56
  • @StevenGruner, yes, there are ways around certain things... but how stupid would it be to have a columns name like File, Where, Select, etc... Some people do dumb things, including "date" for a date something happened. I'm just trying to help PREVENT doing such during any development. – DRapp May 11 '12 at 00:26