SoFunction
Updated on 2025-03-09

A thorough analysis of the method of ASP online compression access database

The principle of ASP online compression ACCESS database is very simple: use the compression function to create a new database file, and then delete and replace the original one! In this case, the compression program only takes a few lines to be OK!

Save the following code as **.asp, put the database file () in the same directory, and execute asp to complete it!

<%
oldDB = ("") 'Change the database address
newDB = ("db_new.mdb") 'Generate temporary files
Set FSO = ("")
Set Engine = ("")
prov = "Provider=.4.0;Data Source="
 prov & OldDB, prov & newDB
set Engine = nothing
 oldDB 'Delete temporary files
 newDB, oldDB
set FSO = Nothing
 "OK"
%>

Below is an ASP online compression ACCESS database encapsulation function

Function CompactDB(dbPath, boolIs97)
Dim fso, Engine, strDBPath
strDBPath = left(dbPath,instrrev(DBPath,"\"))
Set fso = CreateObject("")
If (dbPath) Then
Set Engine = CreateObject("")
On Error Resume Next
If boolIs97 = "True" Then
 "Provider=.4.0;Data Source=" & dbpath, _
"Provider=.4.0;Data Source=" & strDBPath & ";" _
& "Jet OLEDB:Engine Type=" & JET_3X
Else
 "Provider=.4.0;Data Source=" & dbpath, _
"Provider=.4.0;Data Source=" & strDBPath & ""
End If
 
If Err Then
 "<script LANGUAGE='javascript'>alert('The database type cannot be recognized.');(-1);</script>"

end if
 strDBPath & "",dbpath
(strDBPath & "")
Set fso = nothing
Set Engine = nothing
CompactDB = "<script>alert('Compression was successful!  ');javascript:(-1);</script>"
Else
CompactDB = "<script>alert('The database cannot be found!  \nPlease check whether the database path is entered incorrectly!  ');();</script>"
End If
End Function 

Summarize

This is the article about how to compress access databases online by ASP. This is all about this article. For more related ASP online by ASP, please search for my previous articles or continue browsing the related articles below. I hope everyone will support me in the future!