Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP 3 Classic ASP Active Server Pages 3.0 > Classic ASP Databases
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 22nd, 2004, 02:42 PM
Authorized User
 
Join Date: Sep 2004
Location: , , .
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?

Reply With Quote
  #2 (permalink)  
Old November 22nd, 2004, 03:08 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Bangalore, KA, India.
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
Reply With Quote
  #3 (permalink)  
Old November 22nd, 2004, 06:53 PM
Authorized User
 
Join Date: Sep 2004
Location: , , .
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

Reply With Quote
  #4 (permalink)  
Old November 22nd, 2004, 06:57 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Bangalore, KA, India.
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Great! Nice to know on that.

Cheers!

_________________________
- Vijay G
Strive for Perfection
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 09:59 AM.


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