Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 22nd, 2004, 02:42 PM
Authorized User
 
Join Date: Sep 2004
Posts: 62
Thanks: 0
Thanked 1 Time in 1 Post
Default Compact/Repair Access Database On The Fly

Does anyone know how to crun the compact/repair database utility from an ASP page to reduce a databases file size? Everything I have is being hosted on a server that I am unable to install any new files on, and because of the size and activity it is a pain to actually make a copy, manually compact the db's, then re-upload them. I am looking for a way to write an asp page that can do it for me upon calling the page - or even a scheduled task via batch file.

Any ideas?

 
Old November 22nd, 2004, 03:08 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

You can do that using the command line parameters of MSACCESS.exe. Create a batch file and schedule it as a task passing the MDB as a parameter to it. Batch file should contain code similar to the one given below.
Code:
REM --- Backup the file before compact.
"C:\Program Files\Microsoft Office\Office\msaccess.exe" %1 /compact /repair
Hope that helps.
Cheers!

_________________________
- Vijay G
Strive for Perfection
 
Old November 22nd, 2004, 06:53 PM
Authorized User
 
Join Date: Sep 2004
Posts: 62
Thanks: 0
Thanked 1 Time in 1 Post
Default

Awesome - Found an Excellent Way of Doing It In ASP In Case Others Were Wondering -- Code posted below.
------------------------------------------------------------------
  oldFile = Server.MapPath("../database/YourDB.mdb")
  newFile = Server.MapPath("../database/bak.mdb")

  strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="& oldFile
  strConnBak = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & newFile

  Set objJRO = Server.CreateObject("JRO.JetEngine")
   objJRO.CompactDatabase strConn, strConnBak
  Set objJRO = Nothing


  Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
  If objFSO.FileExists(newFile) And objFSO.FileExists(oldFile) Then
   objFSO.DeleteFile(oldFile)
   objFSO.MoveFile newFile, oldFile
   Response.Write "Compact and Repair was successful."
  Else
   Response.Write "Compact and Repair failed."
  End If

  Set objFSO = Nothing

 
Old November 22nd, 2004, 06:57 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Great! Nice to know on that.

Cheers!

_________________________
- Vijay G
Strive for Perfection





Similar Threads
Thread Thread Starter Forum Replies Last Post
Compact and Repair Access Database raguapk VB How-To 8 May 23rd, 2013 10:00 AM
Compact Access Database tang_moor Access VBA 0 January 30th, 2007 02:38 PM
Automatic Compact and Repair Corey Access VBA 4 March 29th, 2006 10:49 AM
is there any auto compact repair utility to buy ? surajguru Access 5 October 15th, 2005 02:45 PM
Compact And Repair Access Database myedu2k4 Pro VB Databases 1 May 25th, 2004 01:43 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.