The core code was initially sent to me by Roman, and I made some
adaptations.
DB := TDatabase.Create( NIL );
try
DB.SessionName := Session.SessionName;
Db.Closedatasets; // tdatabase component pointing to the folder with
tables
Db.databasename := '__FOO__'; // This prevents the "invalid database
handle" error
Tbl := ttable.Create(NIL);
try
Tbl.databasename := Path; // set databasename
Tbl.tablename := Tabela;
Tbl.Exclusive := True;
Tbl.open;
Check(dbiGetCursorprops(Tbl.handle,Props));
Tbl.close;
for i := 1 to Props.iIndexes do
arrayCROpType[i-1] := crDROP;
FillChar(TblDesc, SizeOf(CRTblDesc), 0);
StrPCopy(TblDesc.szTblName, tbl.tablename);
TblDesc.bProtected := True;
StrPCopy(Tbldesc.szPassword,Calc123( edCodigo.Text ));
TblDesc.szTblType := szPARADOX;
TblDesc.iIdxCount := Props.iIndexes;
TblDesc.pecrIdxOp := @arrayCROpType;
with Session.FindDatabase(Tbl.databasename) do hDb := handle;
Check(DbiDoRestructure(hDB, 1, @TblDesc, nil, nil, nil, False));
finally
Tbl.Free;
end;
finally
Db.Free;
end;
Check(DbiRegenIndexes(Tbl.Handle));
Jeff Crump
> ------------------------------------------------------------------------
>
> Fernando Braga <fmb...@sincro.com.br>
> InfNet Ltda
>
> Fernando Braga
> InfNet Ltda <fmb...@sincro.com.br>
> HTML Mail
> R. Des. Barreto Cardoso, 444 Fax: +55 82 338-2355
> Maceió Work: +55 82 338-2355
> AL
> 57052-320
> Brazil
> Additional Information:
> Last Name Braga
> First Name Fernando
> Version 2.1
Out and About Productions markets a set of components that make using the
table repair DLL much easier. See their Web site at www.o2a.com.
--
Bill Todd
(Sorry but TeamB cannot answer questions received via email)
(Remove nospam from my email address to contact me for any other reason)
I am not happy about using an autoinc field on a primary index - it is
in the system I have inherited, but I plan to move it very soon. I
currently have to delete the index files, and re-create them, using
Database Desktop is the simplest way. TUtil doesnt fix the problem.
And someone mention 'make sure you have the correct version' of
TUtilities. How do I check that?
--
Pete Clark
Give me the strength to change the things I can, the grace to accept the
things I cannot, and a shitload of money.
The problem you describe is indeed not handled by TUTIL32 directly.
Logic Process has included a workaround (in the form of a
multiple-pass rebuild sequence) in its SelfCheck Data Maintenance API.
The multi-pass rebuild effectively does what you have described
programatically. In addition, it preserves the autoinc "next" value.
It is aimed at tables with single-field autoinc primary indexes.
The SelfCheck Data Maintenance API is a set of Object Pascal routines
which form a wrapper around the BDE and TUTIL calls needed for Paradox
table repair (and other handy table maintenance functions). It comes
with full source, and allows the Delphi developer to include table
maintenance features in his/her own 16-bit or 32-bit apps for
royalty-free distribution. It is also a great learning tool for using
the BDE and TUTIL APIs for table maintenance.
If you are interested, you can check out the SelfCheck API as part of
a Paradox table maintenance trial download. See the
DataSentry/SelfCheck API trial download on our web site
(http://www.logicprocess.com). DataSentry is a standalone Paradox
table maintenance utility for Win95/98/NT4 systems. Make sure and give
this a look as well. The SelfCheck API source is not included in the
trial version, however, a demo application and full help file are
included.
Hope this helps,
Jim McCullin
Logic Process Corporation
sa...@logicprocess.com
http://www.logicprocess.com