Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to fix Error 41 - Memo file
Message
De
29/06/2007 07:10:45
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
29/06/2007 02:29:16
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
Visual FoxPro
Divers
Thread ID:
01236182
Message ID:
01236737
Vues:
60
Dennis,
I'm sorry then. It works for the most common causes. I didn't think of others. Maybe that memo's header is now severely corrupt (check what's in there using:

do home()+'tools\hexedit\hexedit' with 'so.fpt'

If you see all zeros then forget about recovering anything. Otherwise there are ways that I used back in DOS days (read memo block pointers from dbf records, locate the offset in fpt, extract data etc and write to a new fpt).

If you'd be happy about losing the memo data but recover the dbf itself (and always with a backup), using hexedit change datatype to C from M for memo fields and check first byte, if it's 0x31 then needs no change AFAIK. After opening your table, alter table to put back Ms.
Cetin


>Cetin,
>
>I tried it by doing the following:
>
>- copied your code and pasted into file named MEMOREPAIR.prg
>- copied the SO.DBF, SO.CDX, SO.FPT files into a temp folder
>- then:
>
>SET PROCEDURE TO MEMOREPAIR.PRG
>? RepairMemoHeader( "SO.FPT" )
>
>
>A value of True (.T.) was returned.
>
>Still, when I open SO.DBF, error 41 comes up.
>
>Have I used your code in a wrong way?
>
>The SO.dbf table has more two memo fields. Could this be a reason?
>
>Thanks!
>
>Dennis
>
>
>
>>>Hi All,
>>>
>>>I recently encountered this problem:
>>>
>>>Memo field data (which are notes/remarks of a transaction) seems to have been mixed up!
>>>
>>>The Remarks data found in an invoice transaction appear in another invoice transaction!
>>>
>>>So, I ran my usual routine to PACK, REINDEX all the tables.
>>>
>>>Then 'Memo file "name" is missing or is invalid (Error 41)' came up.
>>>
>>>How does one fix this?
>>>
>>>Thanks
>>>Dennis
>>
>>With a backup you might try if this helps:
>>
>>Function RepairMemoHeader
>>Lparameters tcMemoFilename
>>Local handle, lnFileSize, lnNextBlockPointer, lnBlockSize, lnFirstBlock, lnCalculatedFileSize
>>
>>handle=fopen(tcMemoFilename,12) && Opened readwrite
>>lnFileSize = fseek(handle,0,2) && Get file size
>>* Read header info
>>lnNextBlockPointer = ReadBytes(handle, 0,4,.T.) && Stored in left-to-right format
>>lnBlockSize        = ReadBytes(handle, 6,2,.T.) && Stored in left-to-right format
>>
>>* Specific to me - no blocksize setting to something other than default 0x40
>>If lnBlockSize # 0x40
>>  WriteBytes(handle, 6,2,0x40,.T.)
>>  lnBlockSize=0x40
>>Endif
>>*
>>
>>lnFirstBlock	   = ceiling(512/lnBlockSize) && Possible min lnNextblockpointer
>>lnCalculatedFileSize = lnNextBlockPointer*lnBlockSize
>>
>>* Fix if needs repair
>>If !(lnFileSize >= 512 ;
>>    and lnNextBlockPointer >= lnFirstBlock ;
>>    and lnCalculatedFileSize >= lnFileSize) && Memo needs repair
>>  lnNextBlockPointer = max(lnNextBlockPointer, lnFirstBlock)
>>  lnFileSize = lnNextBlockPointer * lnBlockSize
>>  WriteBytes(handle, 0,4,lnNextBlockPointer,.T.) && Fix next block pointer
>>  =fchsize(handle, lnFileSize) && Fix filesize
>>Endif
>>=fclose(handle)
>>
>>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)
>>
>>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)
>>
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform