Repacking dBase files in Delphi 
Author Message
 Repacking dBase files in Delphi

Does anyone know how to repack a .DBF (dBase file) from within
Delphi? I know you can do it from the database desktop, but we
cannot distribute this.

Otherwise, anyone know of a simple freeware/shareware program
that will do it?

Thanks!

Sean

----------------------------------------------------------------------------
DATAVAULT TECHNOLOGIES              Specialists in Automated Data Protection
PO Box 430,                                       Voice, Fax: +61-2-873-2997

Australia                               WWW: http://www.***.com/ ~dvault/

               *** Your data is your most important asset! **



Tue, 22 Sep 1998 03:00:00 GMT
 Repacking dBase files in Delphi

Quote:

> Does anyone know how to repack a .DBF (dBase file) from within
> Delphi? I know you can do it from the database desktop, but we
> cannot distribute this.

> Otherwise, anyone know of a simple freeware/shareware program
> that will do it?

> Thanks!

> Sean

> ----------------------------------------------------------------------------
> DATAVAULT TECHNOLOGIES              Specialists in Automated Data Protection
> PO Box 430,                                       Voice, Fax: +61-2-873-2997

> Australia                               WWW: http://www.zeta.org.au/~dvault/

>                *** Your data is your most important asset! **

There are freeware components out there to do it.  Look around the
various freeware component pages on the www and you will find them.

Good Luck,  Curt



Wed, 23 Sep 1998 03:00:00 GMT
 Repacking dBase files in Delphi

Quote:


> > Does anyone know how to repack a .DBF (dBase file) from within
> > Delphi? I know you can do it from the database desktop, but we
> > cannot distribute this.

> > Otherwise, anyone know of a simple freeware/shareware program
> > that will do it?

> > Thanks!

> > Sean

> > ----------------------------------------------------------------------------
> > DATAVAULT TECHNOLOGIES              Specialists in Automated Data Protection
> > PO Box 430,                                       Voice, Fax: +61-2-873-2997

> > Australia                               WWW: http://www.zeta.org.au/~dvault/

> >                *** Your data is your most important asset! **

> There are freeware components out there to do it.  Look around the
> various freeware component pages on the www and you will find them.

> Good Luck,  Curt

I've had difficulty finding such a component for Delphi 2.0.  The only
thing I have found so far that seems like it may help is the BDE help
file.

Ciao,

Joe
--
==============================================
Joe Steponaitis         Phone: 902 826-7483
FENIX Software          Fax..: 902 826-1404

Boutilier's Point,
Nova Scotia
CANADA  B0J 1G0         Waaas Sapeneeen???????
==============================================



Wed, 23 Sep 1998 03:00:00 GMT
 Repacking dBase files in Delphi
I have used the following in my Delphi 2.0 Program!

In the project:
DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE

In the Code:

Uses
DBITypes,DBIProcs

DbiPackTable(Table1.DBHandle, Table1.Handle,nil, szdBASE, True);



Wed, 23 Sep 1998 03:00:00 GMT
 Repacking dBase files in Delphi
This is  a hoary old chestnut! This is a re-post of a previous Steve Koterski
message. Hope it helps!

Quote:

>Does anyone know how to repack a .DBF (dBase file) from within
>Delphi? I know you can do it from the database desktop, but we
>cannot distribute this.
>Otherwise, anyone know of a simple freeware/shareware program
>that will do it?
>Thanks!
>Sean

dBASE tables use what is referred to as a "soft delete." When a record in a
dBASE table is "deleted," it is not physically removed from the table.
Instead, it is marked as deleted by the placement of an asterisk (ASCII
decimal 42) in the first byte of the record. The record is then suppressed
for data operations (searches, counts, filtering, etc.). To physically
remove such marked records from the table, it is necessary to perform a
PACK operation (named after the dBASE command for this operation.

In Delphi, the TTable component only supports those operations common to
all table types supported, ommitting those features that are specific to
only one table type. This allows for having only one TTable object, as
opposed to multiple TTable objects: one for each table type.

Because the soft delete is one of those specialized features found only in
the dBASE table, Delphi itself includes no provision for this operation.
However, the Borland Database Engine (BDE) does. BDE API functions can be
called from Delphi applications, making the use of these functions
available even though Delphi does not include them directly. The PACK
operation is effected with the BDE API function DbiPackTable.

Below is an example of the DbiPackTable in use in a Delphi unit. As when
calling any BDE API function, the BDE wrapper units DbiTypes, DbiErrs, and
DbiProcs must be included in the Uses section of the unit making the
function call. This example includes a demonstration of BDE error checking.
BDE functions return a value of type DBIResult that indicates the success
or failure of the function call, no error message will be generated by the
BDE so this is the only way to assess success. Any result but DBIERR_NONE
indicates a failure. With many BDE functions, failed calls cause a
different return code for different reasons for the failure. The various
failure error codes for the DbiPackTable function are demonstrated below.

unit Pack_1;

interface

uses
  SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  Forms, Dialogs, StdCtrls, Grids, DBGrids, DB, DBTables,
  DbiTypes, DbiProcs, DbiErrs;

type
  TForm1 = class(TForm)
    Table1: TTable;
    DataSource1: TDataSource;
    DBGrid1: TDBGrid;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
var
  Error: DbiResult;
  ErrorMsg: String;
  Special: DBIMSG;
begin
  table1.Active := False;
  try
    Table1.Exclusive := True;
    Table1.Active := True;
    Error := DbiPackTable(Table1.DBHandle, Table1.Handle, nil, szdBASE,
      True);
    Table1.Active := False;
    Table1.Exclusive := False;
  finally
    Table1.Active := True;
  end;
  case Error of
    DBIERR_NONE:
      ErrorMsg := 'Successful';
    DBIERR_INVALIDPARAM:
      ErrorMsg := 'The specified table name or the pointer to the ' +
        'table name is NULL';
    DBIERR_INVALIDHNDL:
      ErrorMsg := 'The specified database handle or cursor handle is ' +
        'invalid or NULL';
    DBIERR_NOSUCHTABLE:
      ErrorMsg := 'Table name does not exist';
    DBIERR_UNKNOWNTBLTYPE:
      ErrorMsg := 'Table type is unknown';
    DBIERR_NEEDEXCLACCESS:
      ErrorMsg := 'The table is not open in exclusive mode';
  else
    DbiGetErrorString(Error, Special);
    ErrorMsg := '[' + IntToStr(Error) + ']: ' + Special;
  end;
  MessageDlg(ErrorMsg, mtWarning, [mbOk], 0);
end;

end.

This is a re-post!!
**************************************************************************
Steve Koterski
Product Group Manager
Delphi Technical Support
Borland International, Inc.



Wed, 23 Sep 1998 03:00:00 GMT
 Repacking dBase files in Delphi

Quote:

>This is  a hoary old chestnut! This is a re-post of a previous Steve Koterski
>message. Hope it helps!

>>Does anyone know how to repack a .DBF (dBase file) from within
>>Delphi? I know you can do it from the database desktop, but we
>>cannot distribute this.
>>Otherwise, anyone know of a simple freeware/shareware program
>>that will do it?
>>Thanks!
>>Sean
>Because the soft delete is one of those specialized features found only in
>the dBASE table,
>**************************************************************************
>Steve Koterski
>Product Group Manager
>Delphi Technical Support
>Borland International, Inc.

In reading the above statement, I ASSUME that if I use .DB files
then that explains why I get the following  error:
' [12289], Capability not support' when I used it in my app!

thanks,

-
Scott Martin/MIS
Kvaerner FSSL, Inc.



Sat, 26 Sep 1998 03:00:00 GMT
 
 [ 6 post ] 

 Relevant Pages 

1. Printing DBase files within Delphi App

2. DBCS and Delphi and dBASE files

3. Problem with DBase index files and Delphi (UPPER, STR, etc)

4. Problem using LIKE operator with DBASE files in Delphi

5. Problem accessing dbase III+ files simultaneously with delphi BDE application and a Clipper application

6. How to Pack Dbase file after deleting records in Delphi

7. Delphi with dBase or Delphi with Paradox??

8. Repacking a database

9. dbase files in delphi 32 : I can't use dbase file with more more than 18 fields !!!!!!!!!!!

10. Converting dbase IV files to dbase 3+

11. DBASE III- having problems reading dBASE files to VB

12. Dbase 5 files and Dbase memo field problems


 
Powered by phpBB® Forum Software