ASP Access data backup, restore, Compress class code _ database related

Source: Internet
Author: User
<!--#include file= "config.asp"-->
<!--#include file= "fun.asp"-->
<%
' Database management class
Class Datas
' Backup
Public Sub Bk ()
Set fso=server.createobject ("Scripting.FileSystemObject")
Fso. CopyFile Server.MapPath (Sitedatapath), Server.MapPath (Sitedatabakpath)
Set fso=nothing
Response. Write ("<script language=javascript><!--
Alert (' Backup successful! '); window.location.href= ' datamanage.asp '
--></script> ")
End Sub

' Restore
Public Sub Rt ()
Sdpath = Server.MapPath (Sitedatapath)
sDBPath = Server.MapPath (Sitedatabakpath)
Set Fso=server.createobject ("Scripting.FileSystemObject")
If Fso.fileexists (sDBPath) Then
Fso.copyfile Sdbpath,sdpath
Set fso=nothing
Response. Write ("<script language=javascript><!--
Alert (' Success: You have successfully restored the database! '); window.location.href= ' Datamanage.asp?action=rt '
--></script> ")
Else
Response. Write ("<script language=javascript><!--
Alert (' failed: Please check the path and database name exists '); window.location.href= ' Datamanage.asp?action=rt '
--></script> ")
End If
End Sub

' Compress
Public Sub Dc ()
sDBPath = Server.MapPath (Sitedatabakpath)
Set Fso=server.createobject ("Scripting.FileSystemObject")
If Fso.fileexists (sDBPath) Then
Set Engine =server.createobject ("JRO.") JetEngine ")
If Request ("boolis") = "Then"
Engine.compactdatabase "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" & sDBPath, _
"Provider=Microsoft.Jet.OLEDB.4.0;Data source=" & sDBPath & "_temp.mdb" _
& "Jet oledb:engine type=" & jet_3x
Else
Engine.compactdatabase "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" & sDBPath, _
"Provider=Microsoft.Jet.OLEDB.4.0;Data source=" & sDBPath & "_temp.mdb"
End If
Fso.copyfile sDBPath & "_temp.mdb", sDBPath
Fso.deletefile (sDBPath & "_temp.mdb")
Set Fso = Nothing
Set Engine = Nothing
Response. Write ("<script language=javascript><!--
Alert (' Success: Database has been compressed successfully! '); window.location.href= ' DATAMANAGE.ASP?ACTION=DC '
--></script> ")
Else
Response. Write ("<script language=javascript><!--
Alert (' failed: Database compression failed, please check the path and database name exists! '); window.location.href= ' DATAMANAGE.ASP?ACTION=DC '
--></script> ")
End If
End Sub
End Class
%>
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.