Solved

Fix MDX  (BDE Table MDX)

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

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

Suggested Solutions

Title # Comments Views Activity
Internet Explorer View Settings Question 15 116
code issue 8 154
Mobile Keyboard covers the display of the TMemo 3 96
Installshield for Embarcadero EX 10.1 Berlin 4 60
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

856 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