Search Tools Links Login

Compact Access DB using ASP


This code snippet will compact your Access DB online. You can do this via a web browser!

Original Author: John Tropeano

Inputs

Path to database

Code

<%
Option Explicit
Const THEJETVAR= 4

Function Squish(thePathDB, boolIs97)
Dim fso, Engine, strThePathDB
strThePathDB = left(thePathDB,instrrev(ThePathDB,""))
Set fso = CreateObject("Scripting.FileSystemObject")

If fso.FileExists(thePathDB) Then
   Set Engine = CreateObject("JRO.JetEngine")
  
   If boolIs97 = "True" Then
       Engine.CompactDatabase "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & thePathDB, _
       "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strThePathDB & "temp.mdb;" _
       & "Jet OLEDB:Engine Type=" & JET_3X
   Else
Engine.CompactDatabase "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & thePathDB, _
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strThePathDB & "temp.mdb"
    End If
    fso.CopyFile strThePathDB & "temp.mdb",thePathDB
    fso.DeleteFile(strThePathDB & "temp.mdb")
    Set fso = nothing
    Set Engine = nothing
    Squish = "Your database, " & thePathDB & ", has been Compacted" & vbCrLf
Else
    Squish = "The database name or path has not been found. Try Again" & vbCrLf
End If

End Function
%>
Compact Database

Compacting Dealer database




Enter relative path to the database, including database name.






Check if Access 97 database

(default is Access 2000)







<%
Dim thePathDB,boolIs97
thePathDB = request("thePathDB")
boolIs97 = request("boolIs97")

If thePathDB <> "" Then
    thePathDB = server.mappath(thePathDB)
    response.write(Squish(thePathDB,boolIs97))
End If
%>


About this post

Posted: 2002-06-01
By: ArchiveBot
Viewed: 134 times

Categories

ASP/ HTML

Attachments

No attachments for this post


Loading Comments ...

Comments

No comments have been added for this post.

You must be logged in to make a comment.