RE:Urgente tabla dañada (corrupta)
reparar tablas dañadas:
Si tienes VFP6 o VFP7
Abrelas con Execel y la gradas como .dbf
Si tienes VFP8 o 9 puedes:
1- Renombrar la tabla
2- poner el comando SET TABLEVALIDATE TO 0 en la linea de comandos
3- con un COPY TO compiarla al nombre original.
tambien puedes utilizar estas FUNCTIONES:
chequea_tabla('MITABLA.DBF')
****
FUNCTION chequea_tabla
LPARAMETERS SFILE
****
LOCAL lError, lnError, lcMessage
lError = 0
****
ON ERROR lError=ERROR()
****
SELE H
USE &SFILE
****
IF lError<>0
RepairHeader(SFILE)
ENDIF
****
ON ERROR
****
RELEASE lcOnError
RELEASE lnError
RELEASE lcOnError
****
ON ERROR
****
RETURN
****
****
****
Function RepairHeader
Lparameters tcDBF
Local handle, lnFileSize, lnReccount, lnHeaderSize, lnRecordSize, ;
lnCalculatedReccount, llHasMemo
handle=fopen(tcDBF,12) && Opened readwrite
lnFileSize = fseek(handle,0,2) && Get file size
* Read header info
lnReccount = ReadBytes(handle, 4,4)
lnHeaderSize = ReadBytes(handle, 8,2)
lnRecordSize = ReadBytes(handle,10,2)
lnCalculatedReccount = floor((lnFileSize-lnHeaderSize)/lnRecordSize)
If lnCalculatedReccount # lnReccount && If calculated # recorded fix it
WriteBytes(handle, 4,4,lnCalculatedReccount)
Endif
=fclose(handle)
function WriteBytes
Lparameters tnHandle, tnPos, tnSize, tnNumber, tlLR
Local lcString, lnLowDword, lnHighDword,ix
lcString=''
If tlLR
For ix=tnSize-1 to 0 step -1
lcString=lcString+chr(tnNumber/256^ix%256)
Endfor
Else
For ix=0 to tnSize-1
lcString=lcString+chr(tnNumber/256^ix%256)
Endfor
Endif
=fseek(tnHandle, tnPos,0) && Go to Pos
Return fwrite(tnHandle,lcString)
function ReadBytes
Lparameters tnHandle, tnPos, tnSize, tlLR
Local lcString, lnRetValue,ix
=fseek(tnHandle, tnPos,0) && Go to Pos
lcString = fread(tnHandle, tnSize) && Read tnSize bytes
lnRetValue = 0
For ix=0 to tnSize-1 && Convert to a number
lnRetValue = lnRetValue + asc(substr(lcString,ix+1)) * ;
iif(tlLR,256^(tnSize-1-ix),256^ix)
Endfor
Return int(lnRetValue)
****