This should work for you. I do this on a website of mine.
<%
Dim objJet, objFSO, objFile, strDBFile, strDestFile
Dim strConnect, strDestConnect
strDBFile = Server.MapPath("/db/ShopDb.mdb"
strDestFile = Server.MapPath("/db/dest.mdb"
strConnect = "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=" & Server.MapPath("/db/ShopDB.mdb"
strDestConnect = "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=" & Server.MapPath("/db/dest.mdb"
Set objFSO = Server.CreateObject("Scripting.FileSystemObject"
Set objFile = objFSO.GetFile(strDBFile)
Response.Write "<tr><td>Database file size <b>before</b> compatcing: "& FormatNumber(objFile.Size, 0) &" bytes</td></tr>"
Set objFile = Nothing
Set objFSO = Nothing
Set objJet = Server.CreateObject("JRO.JetEngine"
objJet.CompactDatabase strConnect, strDestConnect
Set objJet = Nothing
Set objFSO = Server.CreateObject("Scripting.FileSystemObject"
Set objFile = objFSO.GetFile(strDBFile)
objFile.Delete
objFSO.MoveFile strDestFile, strDBFile
Set objFile = objFSO.GetFile(strDBFile)
Response.Write "Database file size <b>after</b> compatcing: "& FormatNumber(objFile.Size, 0) &" bytes"
Set objFile = Nothing
Set objFSO = Nothing
%>
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.