Compact Access DB using ASP
Posted: 2002-06-01
By: ArchiveBot
Viewed: 102
Filed Under:
No attachments for this post
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
%>
Compacting Dealer database
Comments on this post
No comments have been added for this post.
You must be logged in to make a comment.