Solved

Fix MDX  (BDE Table MDX)

Posted on 1998-05-15
5
757 Views
Last Modified: 2008-02-01
Would someone PLEASE show me how to:
- Open a table with a corrupted MDX
- Trap the error
- Detach the MDX
- ReCreate a new MDX

Short code example please.

Sincerely,

John Turpin.
0
Comment
Question by:jturpin
  • 2
  • 2
5 Comments
 
LVL 4

Expert Comment

by:BoRiS
ID: 1345821
I once read somewhere that Byte 28 in the DBF file header indicates whether an MDX file is needed.  

I think it was 0 = no MDX needed;
and 1 = MDX needed.

So from there you maybe able to do something...

Later
BoRiS
0
 
LVL 4

Expert Comment

by:BoRiS
ID: 1345822
jturpin

yip I was right it looks something like this

byte    size
28       1 bytes        Production MDX file flag; 01H if there is an MDX,
                             00H if not.

I have a code sample on how to reset this field so that the file thinks there is no MDX
If you interested let me know

Later
BoRiS
0
 
LVL 1

Author Comment

by:jturpin
ID: 1345823
I am interested in your code example. If you could expand
it to include the other points I mentioned I would be
grateful.

Sincerely,

John.
0
 
LVL 2

Accepted Solution

by:
Waldek earned 400 total points
ID: 1345824
Maybe this :} Check . I write from memory :}


unit Fixit;

interface
uses
SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics,
Controls, Forms, Dialogs, StdCtrls, DB, DBTables, Grids, DBGrids;

type

                   TForm1 = class(TForm)

                        Table1: TTable;
                        Button1: TButton;
                        procedure Button1Click(Sender: TObject);
                        private
                        { Private declarations }
                        public
                        { Public declarations }

                   end;

                   var
                   Form1: TForm1;

                   implementation
                   {$R *.DFM}

                   procedure RemoveMDXByte(dbFile: String);
                   {zeros 28 byte}
                   const
                   Value: Byte = 0;
                   var
                   F: File of byte;
                   begin

                        AssignFile(F, dbFile);
                        Reset(F);
                        Seek(F, 28);
                        Write(F, Value);
                        CloseFile(F);

                   end;

procedure TForm1.Button1Click(Sender: TObject);
{Safe open DBF file when MDX is corrupted}

begin

 try
  Table1.DatabaseName := 'c:\temp\';
  Table1.TableName := 'animals.dbf';
  Table1.Open;
   except
    on E:EDBEngineError do
     { MDX not found }
     if Pos('Index does not exist. File', E.Message)>0 then begin
        MessageDlg('MDX not exist,Open without indexes',
                   mtWarning, [mbOk], 0);
       RemoveMDXByte(TheTableDir + TheTableName);
       Table1.AddIndex('Counter', 'AutoInc',[]);
       // Where Counter is index name , and AutoInc a field to        //   index
       // Simulate again click on button to open table
      PostMessage(Button1.Handle, cn_Command, bn_Clicked,0);
                        end;
                        end;

                   end;
                   end.




0
 
LVL 2

Expert Comment

by:Waldek
ID: 1345825
Thanx :}
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now