<% '****************************************************************************** ' VP-ASP 6.50 ' this routine is used only to compate site session database if it gets too large ' No options ' It first closes the shop ' compacts the database ' copies compacted version over existing after saving exising as old_sitesessions ' It then reopends the shop ' Dec 3, 2006 Created '******************************************************************************* shopcheckadmin "" adminpageheader setconfig "xshopclosed","Yes" dim olddb, newdb, strpath, savedb, fso strpath=xdblocation ' get location Set FSO = Server.CreateObject("Scripting.FileSystemObject") ' setup real names Compactsetup xsavesessiondatabase, olddb,strpath, fso, "" compactsetup "temp", newdb,strpath, fso, "Delete" compactsetup "old_" & xsavesessiondatabase,savedb,strpath,fso, "delete" shopwriteheader "Starting to compact database " & olddb & " " & time() Compactdatabase olddb, newdb Compactrenamefiles fso, olddb, newdb, savedb setconfig "xshopclosed","No" shopwriteheader "Compact complete" & " " & time() set fso=nothing adminpagetrailer '*********************************************************************** ' take basic name and turn it it full disk address ' if deletefalg is not empty, delete the file '********************************************************************** sub compactsetup (filename,fullname, strpath, fso,deleteflag) fullname=filename & ".mdb" ' session database If strpath<>"" then fullname = strpath & "\" & fullname end if if ucase(xdatabasetype)<>"DRIVE" Then fullname=server.mappath(fullname) end if if deleteflag<>"" then If fso.FileExists(fullname) Then fso.DeleteFile (fullname) ' debugwrite "deleting " & fullname end if End If end sub Function Compactdatabase(olddb, newdb) Dim Engine, strDBPath, strconn, prov dim olddatabase, newdatabbase prov = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" olddatabase = prov & olddb newdatabase = prov & newdb Set Engine = CreateObject("JRO.JetEngine") Engine.CompactDatabase olddatabase, newdatabase ' compacted ' rename old file to oldxxx ' rename compacted to propername Set Engine = nothing End Function Sub Compactrenamefiles (fso, olddb, newdb, savedb) ' there is no rename so take current file and copy to save database 'debugwrite olddb & " to " & savedb fso.copyfile olddb, savedb ' save current file 'debugwrite newdb & " to " & olddb fso.copyfile newdb, olddb ' overwrite old db with compacted version end sub %>