Solved

*.mdx lost problem (dBase 7)

Posted on 1998-11-06
6
406 Views
Last Modified: 2013-11-24
Hi,

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.

Thanks.
0
Comment
Question by:yysun
  • 2
  • 2
  • 2
6 Comments
 
LVL 4

Expert Comment

by:dwwang
Comment Utility
Hi, yysun, I think you are the yysun on Rich Forum, right?

See http://www.inprise.com/devsupport/bde/bdeapiex, index secction of BDE functions.
0
 

Author Comment

by:yysun
Comment Utility
ÄúºÃ£¡dwwang,¾ÓÈ»µ½ÕâÀïÀ´·¢²ÆÁË£¿

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?
0
 

Expert Comment

by:elkiors
Comment Utility
Is it not possible to rebuild the index files from info within the table ?

Darren
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 4

Accepted Solution

by:
dwwang earned 100 total points
Comment Utility
Use Database Desktop, open the table, when prompt error, select the "open and detach", then the index infomation will be removed from the table.
0
 

Author Comment

by:yysun
Comment Utility
How can I do it using Delphi like Database Desktop does?
0
 

Expert Comment

by:elkiors
Comment Utility
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;

interface

uses BDE, DBTables, DB, sysutils;

procedure PackTable(Table: TTable);

implementation

// 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);
var
  Props: CURProps;
  hDb: hDBIDb;
  TableDesc: CRTblDesc;

begin
  // 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
  begin
    // 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...
    Table.Close;
    // Call DbiDoRestructure...
    Check(DbiDoRestructure(hDb, 1, @TableDesc, nil, nil, nil, FALSE));
  end
  else
    // If the table is a dBASE table, simply call DbiPackTable...
    if Props.szTableType = szDBASE then
      Check(DbiPackTable(Table.DBHandle, Table.Handle, nil, szDBASE, TRUE))
    else
      // Pack only works on PAradox or dBASE; nothing else...
      raise EDatabaseError.Create('Table must be either of Paradox or dBASE ' + 'type to pack');
        Table.Open;
end;

end.


Regards

Darren

0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

This very simple solution applies to a narrow cross-section of the "needs to close" variety. In this case, the full message in Event Viewer was in applog, Event ID 1000: Faulting application iexplore.exe, version 8.0.6001.18702, faulting module …
The System Center Operations Manager 2012, known as SCOM, is a part of the Microsoft system center product that provides the user with infrastructure monitoring and application performance monitoring. SCOM monitors:   Windows or UNIX/LinuxNetwo…
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…

772 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

12 Experts available now in Live!

Get 1:1 Help Now