Improve company productivity with a Business Account.Sign Up


*.mdx lost problem (dBase 7)

Posted on 1998-11-06
Medium Priority
Last Modified: 2013-11-24

If the *.mdx files lost, I used to set the byte number 28 to 0 in *.dbf file.
But Dbase 7 changed DBF file structure. How can I do with it?

Or I think using BDE API is better than to modify the file physically.

Question by:yysun
  • 2
  • 2
  • 2

Expert Comment

ID: 1345988
Hi, yysun, I think you are the yysun on Rich Forum, right?

See, index secction of BDE functions.

Author Comment

ID: 1345989

I've alreadyed check that document, but all the functions there should use a valid handle of the table. But if the mdx file missed the table can not be opened. So no handle can be used?

What can I do then?

Expert Comment

ID: 1345990
Is it not possible to rebuild the index files from info within the table ?

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.


Accepted Solution

dwwang earned 200 total points
ID: 1345991
Use Database Desktop, open the table, when prompt error, select the "open and detach", then the index infomation will be removed from the table.

Author Comment

ID: 1345992
How can I do it using Delphi like Database Desktop does?

Expert Comment

ID: 1345993
Have a look at TTable.DeleteIndex and TTable.IndexDef methods and properties.

you could also call the BDE directly. Below is a block of code that was given to me as an answer on E-E for compacting dBase and Paradox tables. There's a bit in it that uses the BDE to re-index and re-structure the tables. Maybe this is of some use.

unit DBPack;


uses BDE, DBTables, DB, sysutils;

procedure PackTable(Table: TTable);


// This example will pack a Paradox or dBASE table therfore removing already deleted rows in a table.
// This function will also regenerate all out-of-date indexes (maintained indexes).
// This example uses the following input:
// PackTable(Table1)
// The function is defined as follows:

// Pack a Paradox or dBASE table
// The table must be opened execlusively before calling this function...
procedure PackTable(Table: TTable);
  Props: CURProps;
  hDb: hDBIDb;
  TableDesc: CRTblDesc;

  // Make sure the table is open exclusively so we can get the db handle...
  if Table.Active = False then raise EDatabaseError.Create('Table must be opened to pack');
  if Table.Exclusive = False then raise EDatabaseError.Create('Table must be opened exclusively to pack');

  // Get the table properties to determine table type...
  Check(DbiGetCursorProps(Table.Handle, Props));

  // If the table is a Paradox table, you must call DbiDoRestructure...
  if Props.szTableType = szPARADOX then
    // Blank out the structure...
    FillChar(TableDesc, sizeof(TableDesc), 0);
    //  Get the database handle from the table's cursor handle...
    Check(DbiGetObjFromObj(hDBIObj(Table.Handle), objDATABASE, hDBIObj(hDb)));
    // Put the table name in the table descriptor...
    StrPCopy(TableDesc.szTblName, Table.TableName);
    // Put the table type in the table descriptor...
    StrPCopy(TableDesc.szTblType, Props.szTableType);
    // Set the Pack option in the table descriptor to TRUE...
    TableDesc.bPack := True;
    // Close the table so the restructure can complete...
    // Call DbiDoRestructure...
    Check(DbiDoRestructure(hDb, 1, @TableDesc, nil, nil, nil, FALSE));
    // If the table is a dBASE table, simply call DbiPackTable...
    if Props.szTableType = szDBASE then
      Check(DbiPackTable(Table.DBHandle, Table.Handle, nil, szDBASE, TRUE))
      // Pack only works on PAradox or dBASE; nothing else...
      raise EDatabaseError.Create('Table must be either of Paradox or dBASE ' + 'type to pack');





Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Many companies are making the switch from Microsoft to Google Apps ( Use this article to learn more about what Google Apps has to offer and to help if you’re planning on migrating to Google Apps. It is …
Microsoft's Excel has many features that most people will never need nor take advantage of.  Conditional formatting is one feature that you may find a necessity once you start using it.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

585 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