0

Almost ready to throw up the white flag but thought I'd throw it out there. I have an OLD program from 1994 that uses a btrieve dB and renders basic membership info for a gym. The btr file that holds the data will open in notepad and I can search and find all records although the formatting is nearly unreadable. When it opens in the program there is a huge chunk of records missing. It seems to stop on specific records up and down when scrolling.

I know almost nothing about btrieve as it predates my IT career by many years and I've honestly never seen it. Any suggestions on where I should troubleshoot or tools that may help would be much appreciated.

gwpeaks
  • 13
  • 4
  • Is there any logging or errors displayed in the program? BUTIL is a program that can "export" records. In the export, only strings will be readable. If you export the records, do you find the ones missing from the program? An example BUTIL save would be: BUTIL -save Datafile.btr unformattedfile.txt (where Data file.btr is the file the app uses -- the one you opened in Notepad). Depending on the version of Btrieve, you can also use the Function Executor to open the file and navigate through the records. – mirtheil Jan 08 '20 at 15:47
  • No errors displayed. It appears to work correctly, it just stops on the same record when scrolling up or down. I will try saving via butil. I tried salvage, recover, etc. but couldn't get any of them to complete. Likely an error on my part but the entire platform is foreign to me. – gwpeaks Jan 08 '20 at 16:06
  • If BUTIL isn't completing, it should be showing an error. It could be a corrupted file or a corrupted index or something else. Do you know what version of Btrieve is running? Also, BUTIL -STAT will give you statistics on the file including the number of records. That would be a good comparison with the BUTIL -SAVE output. They should match. – mirtheil Jan 08 '20 at 16:57
  • Thanks, those are some good troubleshooting steps. I'll give them a try as soon as possible. – gwpeaks Jan 08 '20 at 21:02
  • I'm not sure the version of btrieve but the butil commands you suggested ran successfully. The - SAVE command saved 1744 records. The STAT command renders 3 total keys and 3 segments. Segment 0 shows 1756 unique values, segment 1 1735 values, and segment 2 1 value. I'll have to research the Stat results to understand them but the file generated by the SAVE switch appears to contain the records that don't render in the program. Any more suggestions? If nothing else the txt file from the SAVE command will at least help with manual reentry so many thanks. – gwpeaks Jan 09 '20 at 00:50
  • How many records are missing from the program? The BUTIL should also show a version. Were there any errors on the SAVE? It seems odd that there were 1744 saved but 1756 records in the STAT. THat might indicate a corruption in the index. – mirtheil Jan 09 '20 at 03:43
  • Unfortunately I have no good way of knowing how many are missing from the program interface. The records are in alphabetical order but there just isn't a feasible way to compare what is rendered to what is saved. No errors with the save though. Btrieve appears to be 6.15.925. I honestly think indexing may be the culprit but I'm not familiar with how it works in this platform. I'm a SQL guy. Is there a way to initiate a reindex or index rebuild? – gwpeaks Jan 09 '20 at 13:21

1 Answers1

1

This sounds like the file may be corrupted although I would expect errors if it was corrupted. One way to rebuild the file is to use BUTIL (and a couple of OS commands).
The steps to rebuild are:

  1. Make a backup of the original file to another directory.
  2. Rename the original file. I like to use change the extension to .OLD.
  3. Delete the original file. It will be recreated in the next step.
  4. Issue the BUTIL -CLONE command (BUTIL -CLONE
  5. Issue the BUTIL -COPY command (BUTIL -COPY

The rebuild is complete. I've use the commands below in the past (changing 'filename' and the extensions to match my files).

copy filename.btr someother\location\filename.btr 
ren filename.btr filename.old 
del filename.btr 
butil -clone filename.btr filename.old
butil -copy filename.old filename.btr
mirtheil
  • 8,952
  • 1
  • 30
  • 29
  • Just ran the commands you suggested. The process runs but I get an error referencing a duplicate key value. This may be my issue. Any suggestion on how to locate the duplicate key? – gwpeaks Jan 09 '20 at 23:41
  • Actually I digress....this appears to have worked. I will do some testing and have the person I'm working on this for test. I will post the results as soon as I know. Thanks to everyone for the suggestions and expertise! – gwpeaks Jan 09 '20 at 23:49
  • Issue was solved by following the above steps to clone and copy. Thanks again to all.. – gwpeaks Jan 10 '20 at 01:48