Asp Access data backup, restoration, and compression code

Source: Internet
Author: User

<! -- # Include file = "config. asp" -->
<! -- # Include file = "fun. asp" -->
<%
'Database Management
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 recovered the database! '); Window. Location. href = 'datamanage. asp? Action = RT'
// --> </SCRIPT> ")
Else
Response. Write ("<script language = JavaScript> <! --
Alert ('failed: Check whether the path and database name exist '); window. Location. href = 'datamanage. asp? Action = RT'
// --> </SCRIPT> ")
End if
End sub

'Compression
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") = "97" 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: the database has been compressed successfully! '); Window. Location. href = 'datamanage. asp? Action = Dc'
// --> </SCRIPT> ")
Else
Response. Write ("<script language = JavaScript> <! --
Alert ('failed: Database compression failed. Check whether the path and database name exist! '); Window. Location. href = 'datamanage. asp? Action = Dc'
// --> </SCRIPT> ")
End if
End sub
End Class
%>

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.