|
热门文章 |
|
|
|
相关文章 |
|
没有相关文章 |
|
|
ASP在线备份、压缩、还原ACCESS数据库 |
来源:百度空间 更新时间:2011/4/24 14:17:48 阅读次数:
字体:[大 中 小大 中 小大 中 小] 我要投稿 |
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <!--#include file="../config.asp"--> <!--#include file="conn.asp"--> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title>数据库管理</title> <link href="images/style.css" rel="stylesheet" type="text/css"> </head> <body> <% Dim fso, f, f1, fc action=request.QueryString("action") filename=request.Form("filename") select case action case "beifen" Set fso = CreateObject("Scripting.FileSystemObject") file1=fso.GetParentfoldername(server.MapPath("./"))&"\data\"&db file2=fso.GetParentfoldername(server.MapPath("./"))&"\data\"&request.Form("filename") fso.copyfile file1,file2 set fso=nothing response.Write("备份成功<br>"&file1&"=>"&file2) response.Write("<meta http-equiv='refresh' content='1;URL=data.asp'>") case "yasuo" Set fso = CreateObject("Scripting.FileSystemObject") file1=fso.GetParentfoldername(server.MapPath("./"))&"\data\"&request.Form("filename") file2=fso.GetParentfoldername(server.MapPath("./"))&"\data\temp.mdb" Set Engine = CreateObject("JRO.JetEngine") Engine.CompactDatabase "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&file1,"Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&file2 fso.CopyFile file1,file2 fso.DeleteFile(file2) set Engine=nothing set fso=nothing response.write("压缩成功") response.Write("<meta http-equiv='refresh' content='1;URL=data.asp'>") case "huanyuan" Set fso = CreateObject("Scripting.FileSystemObject") file1=fso.GetParentfoldername(server.MapPath("./"))&"\data\"&db file2=fso.GetParentfoldername(server.MapPath("./"))&"\data\"&request.Form("filename") fso.copyfile file2,file1 set fso=nothing response.Write("恢复成功<br>"&file1&"=>"&file2) response.Write("<meta http-equiv='refresh' content='1;URL=data.asp'>") case else dataform end select function dataform() %> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td colspan="3"><div align="center">数据库管理</div></td> </tr> <tr> <td width="28%"><div align="right">备份:</div></td> <form name="form1" method="post" action="data.asp?action=beifen"><td width="56%"> <input name="filename" type="text" id="filename" style="width:200px " value="<%= filename()%>"> <input type="submit" name="Submit" value="开始备份" class="button1" onmouseover=this.className="button2"; onmouseout=this.className="button1";> </td></form> <td width="16%"> </td> </tr> <tr> <td><div align="right">压缩:</div></td> <form name="form2" method="post" action="data.asp?action=yasuo"><td> <input name="filename" type="text" id="filename" style="width:200px " value="<%= db%>"> <input type="submit" name="Submit" value="开始压缩" class="button1" onmouseover=this.className="button2"; onmouseout=this.className="button1";> </td></form> <td> </td> </tr> <tr> <td><div align="right">还原:</div></td> <form name="form3" method="post" action="data.asp?action=huanyuan"><td> <select name="filename" id="filename" style="width:200px "> <% Dim fso, f, f1, fc Set fso = CreateObject("Scripting.FileSystemObject") dbpath=fso.GetParentfoldername(server.MapPath("./"))&"\data" Set f = fso.GetFolder(dbpath) Set fc = f.Files For Each f1 in fc temp=split(f1.name,".") fileext=temp(ubound(temp)) if fileext="bak" then response.Write("<option value='"&f1.name&"'>"&f1.name&"</option>") end if next set fso=nothing %> </select> <input type="submit" name="Submit" value="开始恢复" class="button1" onmouseover=this.className="button2"; onmouseout=this.className="button1"; onClick="if(confirm('真的还原么')){return true;}else{return false;}"> </td></form> <td> </td> </tr> </table> <% end function function filename() filename=year(now) if len(month(now))=1 then filename=filename&"0"&month(now) else filename=filename&month(now) end if if len(day(now))=1 then filename=filename&"0"&day(now) else filename=filename&day(now) end if if len(hour(now))=1 then filename=filename&"0"&hour(now) else filename=filename&hour(now) end if if len(minute(now))=1 then filename=filename&"0"&minute(now) else filename=filename&minute(now) end if if len(second(now))=1 then filename=filename&"0"&second(now) else filename=filename&second(now) end if filename=filename&"."&"bak" end function %> </body> </html> |
上一篇文章: ASP利用模板生成静态新闻列表下一篇文章: HTMlEncode函数和HTMLDecode函数 |
|
|