Board index » delphi » Using D1 BDE units : Pb to use Dbidorestructuretable

Using D1 BDE units : Pb to use Dbidorestructuretable

I would like to pack Paradox tables from within D1 app.
PackTable function ( Dbiprocs ) does'nt seem to work ( errror code  :not
supported)
and
using Dorestructure function is tricky : how to get a Table Descriptor ?

Using only CursorProps and Field/index Descs ? or is there any more
direct way ?

I am getting "invalid request" error code.

If anyone has already faced this question....

Thanks in advance

Pierre

 

Re:Using D1 BDE units : Pb to use Dbidorestructuretable


Pierre CHEREL / FRANCE HYBRIDES heeft geschreven in bericht
<34F5D11D.493B4...@france-hybrides.com>...

Quote
>I would like to pack Paradox tables from within D1 app.
>PackTable function ( Dbiprocs ) does'nt seem to work ( errror code  :not
>supported)
>and
>using Dorestructure function is tricky : how to get a Table Descriptor ?

>Using only CursorProps and Field/index Descs ? or is there any more
>direct way ?

>I am getting "invalid request" error code.

>If anyone has already faced this question....

>Thanks in advance

>Pierre

Here is the suggestion from Lloyd's help file. Hope it helps:

Q:  How do I pack a Paradox table?
A:
{ METHOD: PackParadoxTable
  PURPOSE: Pack the currently opened paradox table.

Quote
}

procedure TTableEnhanced.PackParadoxTable;
var
  { Specific information about the table structure, indexes, etc. }
  TblDesc: CRTblDesc;
  { Uses as a handle to the database }
  hDb: hDbiDb;
  { Path to the currently opened table }
  TablePath: array[0..dbiMaxPathLen] of char;
begin
  hDb := nil;
  { Initialize the table descriptor }
  FillChar(TblDesc, SizeOf(CRTblDesc), 0);
  with TblDesc do
  begin
    { Place the table name in descriptor }
    StrPCopy(szTblName, TableName);
    { Place the table type in descriptor }
    StrCopy(szTblType, GetTableType);
    { Set the packing option to true }
    bPack := True;
  end;
  { Get the current table's directory.  This is why the table MUST be
    opened until now }
  Chk(DbiGetDirectory(DBHandle, True, TablePath));
  { Close the table }
  Close;
  { NOW: since the DbiDoRestructure call needs a valid DB handle BUT the
    table cannot be opened, call DbiOpenDatabase to get a valid handle.
    Setting TTable.Active = FALSE does not give you a valid handle }
  Chk(DbiOpenDatabase(nil, 'STANDARD', dbiReadWrite, dbiOpenExcl, nil,
                        0, nil, nil, hDb));
  { Set the table's directory to the old directory }
  Chk(DbiSetDirectory(hDb, TablePath));
  { Pack the PARADOX table }
  Chk(DbiDoRestructure(hDb, 1, @TblDesc, nil, nil, nil, FALSE));
  { Close the temporary database handle }
  Chk(DbiCloseDatabase(hDb));
  { Re-Open the table }
  Open;
end;

{ This code came from Lloyd's help file! }

Other Threads