Jason Sweby
asked on
Compacting Access Databases - Progress?
I can compact an Access database in my application by doing the following:
-------------------------- ---------- -------
Var
Dao, DB1, DB2: Variant;
Begin
Try
Dao := CreateOLEObject('DAO.DBEng ine.35');
DB1 := sAppDir+'Database\Carval.m db';
DB2 := sAppDir+'Database\Compact. mdb';
Dao.CompactDatabase(DB1,DB 2);
Finally
Dao := unassigned;
End;
// Now delete the old table and rename the compacted table with the old name.
DeleteFile(DB1);
RenameFile(DB2,DB1);
-------------------------- ----
This works. No problems there.
However, I would like to display some form of progress bar, just like when you select "Compact Database" in Access itself. How can I measure the progress of this function as it works and the max value for the bar?
--------------------------
Var
Dao, DB1, DB2: Variant;
Begin
Try
Dao := CreateOLEObject('DAO.DBEng
DB1 := sAppDir+'Database\Carval.m
DB2 := sAppDir+'Database\Compact.
Dao.CompactDatabase(DB1,DB
Finally
Dao := unassigned;
End;
// Now delete the old table and rename the compacted table with the old name.
DeleteFile(DB1);
RenameFile(DB2,DB1);
--------------------------
This works. No problems there.
However, I would like to display some form of progress bar, just like when you select "Compact Database" in Access itself. How can I measure the progress of this function as it works and the max value for the bar?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
OK, fair enough, but there must be some way I can make the user think the progress bar is accurate. If you compact databases in Access the progress bar seems accurate enough, so what is a good way of doing this?
Cheat by all means. :-) Whatever it takes to make the bar LOOK like it is correct even if it just making it up.
Cheat by all means. :-) Whatever it takes to make the bar LOOK like it is correct even if it just making it up.
My guess is, the Access GUI has a special 'in' that we, the developer, don't have.
One thing you could try to investigate = monitor the size of the output file during compression = although I'm not sure if Access creates the final output file as it compacts or only at the end.
The difficulty would be in knowing what the final size of the file is - so it'd be difficult to display a status bar type display. It would be more accurate to display # of bytes processed, or something like that. Or guesstimate the percentage of the original size the compacted database will be.
One thing you could try to investigate = monitor the size of the output file during compression = although I'm not sure if Access creates the final output file as it compacts or only at the end.
The difficulty would be in knowing what the final size of the file is - so it'd be difficult to display a status bar type display. It would be more accurate to display # of bytes processed, or something like that. Or guesstimate the percentage of the original size the compacted database will be.
ASKER
Thanks for that.
I'm pretty sure that the output file is built up during compression and not just at the end so I could, as you say, monitor that and try and guess the final size it will be.
Cheers.
I'm pretty sure that the output file is built up during compression and not just at the end so I could, as you say, monitor that and try and guess the final size it will be.
Cheers.
ASKER