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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

database file damaged 2

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Where can I get software to fix a damaged file that foxpro says "Not a database file"?

please advise kherbert1@mediaone.net
 
Is this supposed to be a database? Sometimes the VFP syntax needs a database file and you try feeding it something else and it doesn't like it.
Anyway, where are you told it isn't a database? Is it in code, or have you trying to add it to a project and browse it? --Dave
 
Occassionally, opening the corrupted DBF file in Excel can
correct the problem. However, be sure to take a copy of the damaged files before doing this as it is not foolproof.

If Excel doesn't fix the problem, you will need a product like FoxFix.

 
You may want to go to and get his free VFPVIEW program. It can read and sometimes fix .DBF header problems. Additionally, it'll help you determine the table type - 2.x vs. VFP. If you open a VFP table in an older version of FoxPro you'll also get the "Not a Database" message, even though the table is just fine.

Rick
 
If you attach a free 2.6 table to a VFP dbc and later try to open the table via 2.6, you will get Not a table/DBF. VFP changes the first byte of the .dbf file that identifies it as a .dbf file.

Also, if necessary, you can load a .dbf table into a word file as a text document, strip out the header info, and save the data portion as a text file. (You can tell where the header ends and the data starts). Next, create a structure that is the same as the table you want to salvage and append from your text file as a SDF.

Hope this helps.
 
I should have also noted that if your problem was created by VFP changing your file, try the FREE TABLE command to remove the database reference from the table.
 
I have a FoxPro 2.6a application running on a Netware 4.x server with many users. One particular table is repeatedly getting corrupted(I am getting the "not a table/DBF" error). When I view the contents of the DBF file (using the foxpro editor), I see actual program code inside the DBF, as though the memory contents of one of the PCs was inserted into the beginning of the DBF file. Has anyone experienced anything like this before? Thanks.
 
Hello.

I use this to fix FPW tables:


PARAMETER cBadDbf
SET TALK OFF
IF EMPTY(cBadDbf).OR.PARAMETERS()=0
WAIT WIND 'Wrong table name passed !'
RETURN
ENDIF
STORE FOPEN(cBadDbf,2) to nBadFile
IF nBadFile=-1
WAIT WIND 'Cannot open file '+cBadDbf+' !'
RETURN
ENDIF
STORE FSEEK(nBadFile, 0, 2) to nFileSize
=FSEEK(nBadFile,0)
cStrFour=FREAD(nBadFile,4)
nStrAss=Readx(4)
nStrHead=Readx(2)
nStrRec=Readx(2)
nActual=(nFileSize-(nStrHead+1))/nStrRec
nActual=IIF(nFileSize=nStrHead,0,nActual)
IF nActual<>nStrAss
=FSEEK(nBadFile,0)
cStrFour=FREAD(nBadFile,4)
cStrReplace=RIGHT(REPLICATE('0',8)+Hex(nActual),8)
cStrTmp=''
FOR nContor=1 to 4
cStrTmp=CHR(Dec(SUBSTR(cStrReplace,nContor*2-1,2)))+cStrTmp
ENDFOR
=FWRITE(nBadFile,cStrTmp)
ENDIF
=FCLOSE(nBadFile)
RETURN

*--------------
Function Readx
*--------------
PARAMETER nStrLen
cStrFour=FREAD(nBadFile,nStrLen)
cStrTmp=''
FOR nContor=1 to nStrLen
cStrTmp=RIGHT(REPL('0',2)+Hex(ASC(SUBSTR(cStrFour,nContor,1))),2)+cStrTmp
ENDFOR
nValue1=Dec(cStrTmp)
RETURN nValue1

*--------------
Function Hex && Conversie din baza 10 in 16
*--------------
PARAMETER nInt
PRIVATE nContor,nHex,cStrHex
cStrHex='0123456789ABCDEF'
cHex=''
FOR nContor=7 to 0 STEP -1
nPart=INT(nInt/(16^nContor))
cHex=cHex+SUBSTR(cStrHex,nPart+1,1)
nInt=nInt-nPart*(16^nContor)
ENDFOR
DO WHILE LEFT(cHex,1)='0'.AND.LEN(cHex)>1
cHex=SUBSTR(cHex,2)
ENDDO
RETURN cHex

*--------------
Function Dec && Conversie din baza 16 in 10
*--------------
PARAMETER cHex
PRIVATE nContor,nInt,cStrHex
cStrHex='0123456789ABCDEF'
nInt=0
FOR nContor=LEN(cHex)-1 to 0 STEP -1
nInt=nInt+(16^nContor)*(AT(SUBSTR(cHex,LEN(cHex)-nContor,1),cStrHex)-1)
ENDFOR
RETURN nInt
Grigore Dolghin
Class Software
Bucharest, Romania
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top