[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Fix MDX  (BDE Table MDX)

Posted on 1998-05-15
5
Medium Priority
?
825 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

650 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