FoxPro/Visual FoxPro - Urgente tabla dañada (corrupta)

 
Vista:

Urgente tabla dañada (corrupta)

Publicado por Luis Alberto (46 intervenciones) el 17/05/2007 01:37:23
Que tal foristas,
tengo un problema muy grande, al querer utilizar una tabla sale un error de que esta corrupta y necesita ser reparada.
Esto se dio cuando el pc se quedó sin energía y se dañaron tablas q estaban siendo usadas

POR FAVOR AYUDA URGENTE,
GRACIAS DE ANTEMANO
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
sin imagen de perfil

RE:Urgente tabla dañada (corrupta)

Publicado por jesus cordero (405 intervenciones) el 18/05/2007 01:47:12
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)
****
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
1
Comentar

RE:Urgente tabla dañada (corrupta)

Publicado por Luis Alberto (46 intervenciones) el 18/05/2007 02:59:23
Si funcionó lo de TableValidate, gracias por todo

Exitos
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar