Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Data Corruption on table in Visual Fox Pro 6.0

Status
Not open for further replies.

rcne

IS-IT--Management
Jul 17, 2000
8
US
We are having a problem with one of our .dbf tables where we pull up a simple form and see corrupted data. When we actually go into the table itself and browse the record, we even see some numeric data in alpha types and alpha characters in numeric field types. The cause of the corruption is unknown to us, but when eliminating what it can't be, it seems to be something in VFP. We recently upgraded to 6.0 hoping that would cure the problem, but it hasn't. Has anyone experienced this? Does anyone know how to fix this?

Kevin Hickman
gocadle@cadleco.com
 
Does this occur on more than one computer? My first suspicion is honestly a hardware issue, and if you can get it to work properly on a different computer that would show you for sure.
 
I've found this data corruption to usually be one of the following:
a) Bad Disk on "Server"
b) Bad network card
c) Bad network cabling/connection
d) Bad memory (used in caching data) on either server or workstation.
e) Power loss on server

Rick
 
I've run into this problem before because I think we have some bad cabling in our network or sometimes data gets corrupted when it is compressed and uncompressed.

Anyway, I have this program that takes the bad characters [CHR(0)] out. Here is the code:

*** This program goes through every field of every record in a table and removes CHR(0)
*** This stupid character screws up copying and appending records.

nCorrect = 0
nCheck = 0

USE GETFILE() IN 1
SELECT 1
COPY STRUCTURE EXTENDED TO temp

USE temp IN 2

SELECT 1
SCAN && Go through each record of the file being cleaned
SCATTER TO aRecord MEMO && Copy current record to an array
SELECT 2
FOR nField = 1 TO RECCOUNT() && Go through each element of the array
SELECT 2
GO (nField)
IF field_type = 'M' OR field_type = 'C' THEN && Only cleans memo or character fields
SELECT 1
IF CHR(0)$aRecord(nField) = .T. THEN && This element needs to be cleaned
nCharacter = 1
DO WHILE nCharacter <= LEN(aRecord(nField)) && Go through each character in the element
IF SUBSTR(aRecord(nField),nCharacter,1) = CHR(0) THEN
aRecord(nField) = LEFT(aRecord(nField),nCharacter-1) + ;
IIF(LEN(aRecord(nField))=nCharacter,'',SUBSTR(aRecord(nField),nCharacter+1)) && This line takes out the CHR(0)
nCharacter = nCharacter - 1
nCorrect = nCorrect + 1
ENDIF
nCharacter = nCharacter + 1 && Move to next character
ENDDO
ENDIF
ENDIF
ENDFOR
SELECT 1
GATHER FROM aRecord MEMO && Replace record from array with each field cleaned

@ 1,1 SAY ALLTRIM(STR(RECNO()/RECCOUNT()*100,7,2)) + '% complete.'
@ 2,1 SAY ALLTRIM(STR(nCorrect,10)) + ' corrections.'

ENDSCAN

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top