Solved

Fix MDX  (BDE Table MDX)

Posted on 1998-05-15
5
767 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

864 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

24 Experts available now in Live!

Get 1:1 Help Now