How to troubleshoot to resolve suspected corruption in Visual FoxPro
This article provides basic steps to begin troubleshooting data corruption problems encountered in Visual FoxPro.
Original product version: Visual FoxPro
Original KB number: 193952
When you use Microsoft Visual FoxPro, you may sometimes run into problems. The cause of these problems is not always immediately clear. In such situations, you need a general method or a process of trial and error troubleshooting techniques. The steps in the 'More Information' section provide beginning steps for the troubleshooting process. The steps also apply to the distributed application .exe files that are written in Visual FoxPro that you install on client computers.
The first step is to make sure that you have an error free installation of the Visual FoxPro product. In our experience, if you install the most recent version in the same folder as the previous version, the installation does not complete properly or reliably. This is because all of the files may not update or install correctly.
If Visual FoxPro is installed on local computers use the following steps:
Back up your files. Save any files on the computer that you want to keep; especially database (.dbc/.dct/.dcx) files and table (.dbf/.fpt/.cdx) files, as well as other source files such as
.pjx, .pjt, .vcx,.vct, .scx,.sct, .mnx .mnt, .frx .frt, and the Config.fpw file.
Remove Visual FoxPro completely, and then delete the directory where it was installed.
This step is not necessary if you are in Step 3. You need to install into a completely new subdirectory.
Close all open or running applications. Using CTRL+ALT+DELETE opens the system Task Manager allowing you to see what applications are currently running.
Do not close Explorer because it is the desktop user interface.
Perform operating system disk error check by using Scandisk or a third-party disk repair tool. These tools check and try to fix any lost clusters on the hard drive. After this, run the Disk
Defragmenterutility (in Windows XP) or other tool to optimize the disk.
Once again, close all open or running applications, (See step 1c).
Install Visual FoxPro into a new or different directory location.
A successful product installation means that you do not receive any errors during the installation. Errors during installation indicate an unreliable installation of Visual FoxPro. If errors occur:
- Note any errors during installation process.
- Boot the machine in Safe Mode or Safe Mode with Networking. Furthermore, temporarily disable any anti virus software.
- Start at Step 1 again.
If this is your second time through this process, try using the Custom, Minimal or Laptop installation, instead of Complete.
If Visual FoxPro is installed on network server:
- You must have an error free installation of Visual FoxPro.
- Generally, you cannot perform ScanDisk or other disk integrity checking while a Local Area Network (LAN) or Server is running.
- Remove and reinstall Visual FoxPro until no installation errors are received.
Eliminate all DUPLICATE source code and project files. This includes both network and local drives.
Duplicate files cause multiple problems. Make sure that you retain the correct version of the source or project file, and ONLY the correct one.
If your project contains a DATABASE/DBC, VALIDATE the database.
Please refer to the OPEN DATABASE command in the Visual FoxPro Help file for details.
Use the OPEN DATABASE
EXCLUSIVE VALIDATE command.
Errors indicate table (.dbf) or index (.cdx) corruption.
Clean up the project.
Open your project and then from the Project menu, choose "Clean Up Project".
Errors indicate project (.pjx) file corruption.
As a way to test with a different file, USE the file as you would a table (.dbf), copy the .dbf structure to a new file, and append the records from the original table, and rename the files. This method necessitates the creation of a new index (.cdx) file, if needed.
The following steps use a sample table (.dbf) file named Customer.dbf.
Database, Project, Screen, Menu, Report, and Label files are actually Table (.dbf) files that have a different extension other than .dbf.
If your file is open in the Visual FoxPro interactive or design environment, close it.
Issue the following commands in the Visual FoxPro Command window:
USE customer.dbf && Must specify extension if other than .dbf. ? RECCOUNT() && Note the number of records in the table. COPY STRUCTURE to newfile.dbf USE newfile.dbf && Empty file structure without records. APPEND FROM customer.dbf && Bring in records from original table. ? RECCOUNT() && Compare number of records with original file. RENAME customer.dbf to oldcust.dbf RENAME newfile.dbf to customer.dbf
A difference in the number of records in the new file as compared to the original file. This is an indicator that file corruption exists in the original file.
Test on a different computer or in a different computer environment such as a single user environment if problems occur in a multiuser environment or use a different operating system.
If corrupt, the FoxPro resource file may cause problems.
One way to test whether the resource file is a factor is to replace the file. Here are two ways to determine the name and location of the FoxPro resource file:
You can determine the location of the currently active resource file by using the following FoxPro command:
You can specify the FoxPro resource file in the FoxPro configuration file, named Config.fpw by default. If the resource file specified by the configuration file does not exist, FoxPro creates one.
Use the following FoxPro command to determine the location of the configuration file:
The configuration file is an ASCII text file, which can be edited with any editor that saves it in ASCII text format. The easiest way to edit the currently active FoxPro configuration file is with the following command:
MODIFY FILE SYS(2019)
The configuration file may contain a line of text that specifies the location and name of the resource file, such as follows:
If so, comment that line out by placing an asterisk (*) at the beginning of the line.
Add a new line such as the following:
RESOURCE=<path>\newjunk.dbf && Any name of your choice.
Restart FoxPro for the new setting to take effect.
Create a log file that contains the results of the preceding steps for future reference.
For more information about the setup requirements for Visual FoxPro, see the Readme.hlp Windows Help file that is located in the directory of the Visual FoxPro installation or on the original installation CD-ROM.
Visual FoxPro Help; search on: 'Installing Visual FoxPro', 'Testing and Debugging Applications'.