Solved

PACK for PARADOX tables

Posted on 1998-04-23
11
449 Views
Last Modified: 2008-02-01
Hello! Please, give me example, how to PACK PARADOX tables, for deleting 'deleted' records... I need code example!!!
I have table "main.db".
Thanx...
0
Comment
Question by:hind
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 3
  • +1
11 Comments
 
LVL 4

Expert Comment

by:jeurk
ID: 1336581
Hi,
here you have the source code of a component that can pack dbase tables and paradox tables. by the way it can regenerate indexes too. It's not my code but it's freeware.
If you don't know what to do with that let me know.
Jeurk


------------------
{============================ BSPKTBL Distribution Notes ==================================}
{DESCRIPTION
-----------
BSPkTbl is a simple improved component for Delphi 1 and 2 {not yet tested on 3, but should be ok)
BSPkTbl includes two additional functions which Borland seem to have 'forgotten' - a simple
and effective way of packing and reindexing Dbase and Paradox tables. TBSPktbl is a direct
replacement for  TTable in your applications, and may call two extra functions:

1. PACK (returns 'True:boolean' if successful)
2. REGENINDEXES (returns 'True:boolean' if successful)



{COPYRIGHT NOTICE}
{BSPktbl is distributed as FREEWARE, but remains the COPYRIGHT of
BUSINESS SOFTWARE (UK) (email  ebinfo@compuserve.com ). Business Software grants you the right
to include this compiled component in your DELPHI application, whether COMMERCIAL, SHAREWARE, or
FREEWARE, BUT YOU MAY NOT DISTRIBUTE THIS SOURCE CODE OR ITS COMPILED .DCU  IN ANY FORM OTHER
THAN AS IT EXISTS HERE; COMPLETE WITH THIS NOTICE AND ALL THE TEXT BELOW. BSPktbl may be included
in any shareware or freeware libraries or compilation disks, provided no charge other than the
usual media cost recovery is made.}

{IF YOU HAVE ANY DOUBTS ABOUT WHETHER YOU MAY LEGALLY USE OR DISTRIBUTE THIS COMPONENT,
CONTACT BUSINESS SOFTWARE BY E-MAIL.}

{VISIT BUSINESS SOFTWARE'S WEB SITE AT HTTP://OURWORLD.COMPUSERVE.COM/HOMEPAGES/EBINFO/  for
more interesting components and applications}

{WARRANTY / ACCEPTANCE OF LIABILITY / INDEMNITY}
{ABSOLUTELY NONE WHATSOEVER}


{INSTALLATION}
{1.Copy this file into your DELPHI/LIB directory, or wherever your library files are kept}
{2.Select OPTIONS|INSTALL COMPONENTS|ADD...}
{3.ADD This file; BSPktbl.PAS to the INSTALLED UNITS listbox}
{4.Click OK}

{USING BSPktbl}
{Use just as you would a normal TTable component. Before calling PACK or REGENINDEXES, you must
make sure that either:

     The TABLETYPE property is correctly set to reflect the tabletype i.e. ttDbase or ttParadox

     or:

     The TABLENAME property must have the file extension added i.e. 'ANIMALS.DBF' or 'BIOLIFE.DB'


EXCLUSIVE must be set to true!}

unit BSPktbl;

interface
uses dbtables,db,dbiprocs,dbierrs,dbitypes,classes,sysutils;

Type
TBSPktbl=class(TTable)
private
  ftblprops:curprops;
  bopen:boolean;
  ex:string[4];

  procedure fixtabletype;
public
  constructor create(aowner:Tcomponent); override;
  destructor  destroy; override;
  function pack:boolean;
  function regenindexes:boolean;
end;


procedure register;
procedure bdecheck(BDERes: DBIResult);

implementation

procedure register;
begin
registercomponents('BSoft',[TBSPktbl]);
end;

constructor TBSPktbl.create(Aowner:Tcomponent);
begin
inherited create(aowner);
end;

destructor TBSPktbl.destroy;
begin
inherited destroy;
end;



procedure BDECheck(BDERes: DBIResult);
begin
if (BDERes <> DBIERR_NONE) then DBIError(BDERes);
end;

function TBSPktbl.pack:boolean;
var
hDB:                   hDBIdb;
pTblDesc:              pCRTblDesc;

procedure packpdx;
begin
result:=false;
GetMem(pTblDesc,sizeOf(CRTblDesc));
FillChar(pTblDesc^,SizeOf(CRTblDesc),0);
AnsiToNative(DBLocale,TableName,pTblDesc^.szTblName,255);
pTblDesc^.szTblType := FTblProps.szTableType;
pTblDesc^.bPack := True;
hDB := DBHandle;
close;
   try
   BDECheck(DBIDoRestructure(hdb,1,pTblDesc,nil,nil,nil,False));
   result:=true;
   finally
   if pTblDesc <> nil then FreeMem(pTblDesc,sizeOf(CRTblDesc));
   end;
end;

procedure packdbf;
begin
try
open;
BDECheck(DBIPackTable(DBHandle,Handle,nil,nil,TRUE));
result:=true;
except
result:=false;
end;
end;

begin
result:=false;
pTblDesc := nil;
bopen:=active;   {store previous state}
fixtabletype;
if exclusive then
 begin
    try
    open;
    if (tabletype=ttParadox) then  packpdx {paradox}
      else if (tabletype=ttDBASE) then  packdbf {Dbase}
    except
    result:=false;
    end;
 end;
active:=bopen;     {restore previous state}
end;


function TBSPktbl.regenindexes:boolean;
begin
result:=false;
bopen:=active;
fixtabletype;
if exclusive then
  begin
   try
   open;
   BDEcheck(dbiregenindexes(handle));
   result:=true;
   except
   result:=false;
   end;
  end;
active:=bopen;
end;




procedure TBSPktbl.fixtabletype;
begin
if active then close;
ex:=uppercase(extractfileext(tablename));
if (ex='') then
   begin
        if (tabletype=ttparadox) then tablename:=tablename+'.DB' else
           if (tabletype=ttdbase) then tablename:=tablename+'.DBF';
   end
else
  begin
  if (ex='.DBF') then tabletype:=ttDBASE else
   if (ex='.DB') then tabletype:=ttParadox else
      tabletype:=ttDefault;
   end;
end;



end.

0
 

Author Comment

by:hind
ID: 1336582
Opssssss!!!!!! And now I need help! And I need it very much!!! ;)
problem is: when I made pack for my PARADOX table, all passwords were deleted:( How I can save passwords? Or how I can get
TblDesc:CRTblDesc from my table? Thanx...
0
 

Author Comment

by:hind
ID: 1336583
I have used the component listed above - as well as, another freeware components TPacker & RX Library - they all remove teh password.  Don't know why this happens but I haven't found an answer either :o(
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Expert Comment

by:d4jaj1
ID: 1336584
Hi all,

Have found some components on a disk, maybe you can use these? I 'll give the titles on monday... If these don't work properly, then .... It's time to develope one ourselfs, don't you think?

Regards, ZIF.


0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1336585
Hi all!!!
How I can see, it's the BIG problem :) And I think, that it's time to write own library :] He-he, and I'm ready to do this but there is 1 problem... Who knows, how to get variable of type CRTblDesc from any TABLE?
Best Regards,
Hind
0
 

Author Comment

by:hind
ID: 1336586
Hi,

I won't help you more hind, cause it's not my knowledge. I could supply a component
that is working for me. But no more. Sorry. Try to send your projects to the others
experts if they want.
Good luck
0
 
LVL 4

Expert Comment

by:jeurk
ID: 1336587
Probably doesn'r make a lot of sense to 're-create the wheel'.  Why not just fix one of the components/procedures that don't work.  The best cabdidate would be the Borland BDE Pack example on their website.  It doesn't work at ALL!!  I'm guessing that if we can get that one to work, the passwords won't be removed - maybe?
0
 
LVL 3

Expert Comment

by:d4jaj1
ID: 1336588
Ok, here are the components I know of, BUT never tested them! Just found them this week on a disk.... If you want to try them out, then just ask them, give me your email or email me...

BDETools 1.0
DBPack & Copy
DBUtlty
Packing DBase & Paradox Tables in Delphi
TTableDBF


Tom.Deprez@uz.kuleuven.ac.be

Regards, ZiF.
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1336589
Hind,

I have a utility that will work for you.  It is part of the RXLib called PackTable.  In the eariler versions of teh library, it removed Paradox passwords, however, one of teh authors have sent me a patch.  If your already using the RXLib,  add this line to the Pack procedure after line bPack := True;

bProtected := FCurProp.bProtected;

If your not already using RxLib - you should.  It has over 25 different Freeware components and several other procedures that really help your application look more professional. The newest version 2.40 fixes teh issue above, as well as, adds editable DB Lookup, improved app events, GIF animator, GIF list and more.

Download teh RXLib from http://rx.demo.ru.  This is the only utility I've seen that doesn't remove the password.

Good Luck!

Jay

Zif - Might as well use the updated RxLib instead of trying to fix/create another.


0
 
LVL 3

Accepted Solution

by:
d4jaj1 earned 80 total points
ID: 1336590
Hi Jay, 10x for letting me know! Regards, Zif.
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1336591
OK... I'll try to look this RxLib. And I think that it will be decision for our problem ;) And 80 points I give you, d4jaj1.
Thanx!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Simple Delphi Question 9 104
how to resize animated Gif image in delphi ? 1 45
Graphics32 under Delphi 10.1 Berlin 2 125
Broadcast a message using ICS 2 20
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

740 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