Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 3 of 3 total
Thread Automating V3 to 4 upgrading...
Wed, Oct 9 2013 11:22 AMPermanent Link

Richard

ENT Technologies

Wow, I'm amazed that version 4.36 still works with Delphi 5! That means I can put off rebuilding my rather large application in XE3 for just a little longer.

What I would like to do is have an auto upgrade feature, so that if my application attempts to open a version 3 table, it gets immediately upgraded to a version 4 table.

I'm not sure of the syntax of the exception and what I should be trapping for (I've never been good with exceptions...). I want to do something like this:

try
   tbl.open;
except
  on EDBISAMEngineError //not sure what goes here. Error is DBISAM_OLDVERSION
end;
Wed, Oct 9 2013 1:22 PMPermanent Link

Richard

ENT Technologies

Richard wrote:


I'm not sure of the syntax of the exception and what I should be trapping for (I've never been good with exceptions...). I want to do something like this:

try
   tbl.open;
except
  on EDBISAMEngineError //not sure what goes here. Error is DBISAM_OLDVERSION
end;
------------------------------------------------------------------

Sorry, I just got to page 31 of the manual. I know how to do it now. I would delete this post if I knew how...
Fri, Oct 11 2013 8:12 AMPermanent Link

Walter Matte

Tactical Business Corporation

Here is a routine that will do it... just call it prior to Opening the Database - it will only Upgrade it the Tables need it.....

Just Call ... and pass in the TDBISAMDatabase

     DoDBIsamUpgrade(dbisamDatabase1);


procedure Tdm1.DoDBIsamUpgrade(aDB: TDBISAMDatabase;
                              aOnProgress: dbisamtb.TSteppedProgressEvent = nil;
                              aOnLog: dbisamtb.TLogEvent = nil);
var
  StL    : TStringList;
  tbl    : TDBISAMTable;
  ii     : integer;
  SavePrivateDir : string;
begin

  SavePrivateDir := aDB.Session.PrivateDir;
  aDB.Session.PrivateDir := aDB.Directory;
  
  StL := TStringList.Create;
  try
    aDB.Session.GetTableNames(aDB.DatabaseName, StL);
    for ii := 0 to StL.Count - 1 do
    begin
      tbl := TDBISAMTable.Create(nil);
      try
        tbl.TableName := StL[ii];
        tbl.DatabaseName      := aDB.DatabaseName;
        tbl.SessionName       := aDB.SessionName;
        tbl.OnUpgradeProgress := aOnProgress;
        tbl.OnUpgradeLog      := aOnLog;
        tbl.OnRepairProgress  := aOnProgress;
        tbl.OnRepairLog       := aOnLog;

        if Copy(tbl.VersionNum,1,1) = '3' then
        begin
          // Give Message to User ..... >>>  frmWait.Msg1 := 'Upgrading Table ' + StL[ii];
          tbl.UpgradeTable;
        end;
      finally
        FreeAndNil(tbl);
      end;
    end;
  finally
    FreeAndNil(StL);
  end;

  aDB.Session.PrivateDir := SavePrivateDir;
  
    
end; { DBISAMUpgrade }



Walter
Image