Popular Articles | Latest Articles | Categories | RSS Feeds

Login  |  Register

Compacting an Access database from ASP code

Published on 6/13/2008 by Dotnetindex
 Vote this tutorial:

More articles in ASP

 

This source code can compact and repair your MS-Access database files. If you compact your access files regularly, it will work more faster and secure. Also you will save some hard disk space.

 

<%
  oldFile = Server.MapPath("db.mdb")
  newFile = Server.MapPath("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
  %>

Comments:
no comments submitted


Only members can write comments.Please, login / register to write comment.

Latest Posts

Active News Manager - news management system



ASP.NET Resources, Reviews

ASP Resources, Reviews

PHP, ASP, .NET, JSP Resources, Reviews




Who's online

  • There 39 online users.

ASP.NET Resources, Reviews

ASP Resources, Reviews

PHP, ASP, .NET, JSP Resources, Reviews

Hotscripts.com Free Photoshop, Flash and 3DS MAX tutorials