By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,254 Members | 2,365 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,254 IT Pros & Developers. It's quick & easy.

Compact backend of databse while front Open

P: 49
Can someone give some advice on this . I have a split db, we want to compact the backend and the end of a process. This DB is running in virtual office.
Thanks
Feb 27 '07 #1
Share this Question
Share on Google+
4 Replies


Rabbit
Expert Mod 10K+
P: 12,366
Expand|Select|Wrap|Line Numbers
  1. CompactDatabase "File Path", "Compacted File Path" ' Must be different
  2. Kill "File Path"
  3. FileCopy "Compacted File Path", "File Path"
  4. Kill "Compacted File Path"
Feb 28 '07 #2

NeoPa
Expert Mod 15k+
P: 31,494
As there may be situations where the file(s) are locked, it's probably a good idea to use 'On Error Resume Next' code to allow this code to process through.
Expand|Select|Wrap|Line Numbers
  1. On Error Resume Next
  2. CompactDatabase "File Path", "Compacted File Path" ' Must be different
  3. Kill "File Path"
  4. Name "Compacted File Path" As "File Path"
  5. Kill "Compacted File Path"
  6. On Error Goto 0
Also, probably better to use the rename command (Name ... As ...) rather than a copy.
Mar 1 '07 #3

Rabbit
Expert Mod 10K+
P: 12,366
I only used the Copy because I couldn't find the rename command lol. Actually, I was looking for a move command and couldn't find that either.

Either way, you would get rid of the last kill statement if you use the rename command.
Mar 1 '07 #4

NeoPa
Expert Mod 15k+
P: 31,494
I only used the Copy because I couldn't find the rename command lol. Actually, I was looking for a move command and couldn't find that either.
I believe the Name command can work as a move in the same way as the 'mv' command in Unix does both. You'd have to test to be sure though.
Either way, you would get rid of the last kill statement if you use the rename command.
In fact, if it hadn't been there already I would have added it.
Consider the rename failing due to the file being open when the rename is attempted. This code won't give proper error messages, but at least in that case it will tidy up the file that's left behind.
Mar 1 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.