?
Solved

Fix MDX  (BDE Table MDX)

Posted on 1998-05-15
5
Medium Priority
?
810 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 1200 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month9 days, 16 hours left to enroll

762 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