Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is it possible to compact database from a web page?

Status
Not open for further replies.

Kenos

Programmer
Jul 21, 2002
28
0
0
US
Hello All,

Is it possible to compact an Access database from a web page?
I have searched and have not found anything on this
Subject

Thanks In Advance
 
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(&quot;/db/ShopDb.mdb&quot;)
strDestFile = Server.MapPath(&quot;/db/dest.mdb&quot;)
strConnect = &quot;PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=&quot; & Server.MapPath(&quot;/db/ShopDB.mdb&quot;)
strDestConnect = &quot;PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=&quot; & Server.MapPath(&quot;/db/dest.mdb&quot;)
Set objFSO = Server.CreateObject(&quot;Scripting.FileSystemObject&quot;)
Set objFile = objFSO.GetFile(strDBFile)
Response.Write &quot;<tr><td>Database file size <b>before</b> compatcing: &quot;& FormatNumber(objFile.Size, 0) &&quot; bytes</td></tr>&quot;
Set objFile = Nothing
Set objFSO = Nothing
Set objJet = Server.CreateObject(&quot;JRO.JetEngine&quot;)
objJet.CompactDatabase strConnect, strDestConnect
Set objJet = Nothing
Set objFSO = Server.CreateObject(&quot;Scripting.FileSystemObject&quot;)
Set objFile = objFSO.GetFile(strDBFile)
objFile.Delete
objFSO.MoveFile strDestFile, strDBFile
Set objFile = objFSO.GetFile(strDBFile)
Response.Write &quot;Database file size <b>after</b> compatcing: &quot;& FormatNumber(objFile.Size, 0) &&quot; bytes&quot;
Set objFile = Nothing
Set objFSO = Nothing
%>
 

Thank You baddos

This is Great.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top