注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

冰的博客,非一样的精彩!

微笑着面对生活,找寻通往特雷比西亚的桥!

 
 
 

日志

 
 
关于我

人就是一个充满矛盾的个体,我快乐,我悲伤,我用自己的方式生活。有时真的感到很累,好想把自己放逐到天际,静静的体会孤独。我常说的一句话就是:“微笑着面对生活”,虽然生是一种痛苦,但我选择快乐的活着。我是冷雨中孤寂的冰,泪水早已随风而去,我要做最好的自己。

网易考拉推荐

在线对加密的access数据库压缩、备份、恢复(asp)  

2006-01-20 14:59:58|  分类: 电脑网络 |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |

在线对加密的access数据库压缩、备份、恢复

 

下面的代码是关于access数据库在线压缩、备份和恢复的源代码,这些代码中关于加密access数据库的压缩是这次的重点。

<%

select case request("action")

case "resetdata"

call resetdata()

case "deldata"

call deldata()

case "godata"

call godata()

case "backdata"

if request("act")="Backup" then

call updata()

else        

call backdata()

end if

case "redata"

if request("act")="data" then

dim Dbpath,backpath,fso

                     Dbpath=request.form("Dbpath")

                     backpath=request.form("backpath")

                     if dbpath="" then

                     response.write "请输入您要恢复成的数据库全名"   

                     else

                     Dbpath=server.mappath(Dbpath)

                     end if

                     backpath=server.mappath(backpath)

             

                     Set Fso=server.createobject("scripting.filesystemobject")

                     if fso.fileexists(dbpath) then                                   

                     fso.copyfile Dbpath,Backpath%>

<table width="100%" align="center" border="1" cellspacing="0" cellpadding="0" rules=none class=3d>

<tr><td class=title   height=22><b>&nbsp;<img src=img/ie.gif border=0 width=15 height=15 align=absMiddle>&nbsp;成功恢复!</B></td></tr>

<tr height=100 class=bg><td align="center">您的数据库已经成功恢复!请到首页进行调式! </td></tr></table>

<%else%>

<table width="98%" align="center" border="1" cellspacing="0" cellpadding="2" bordercolor=<%=border%>>

<tr><td class=title align="center"  height=30>错误提示!</td></tr>

<tr height=100><td align="center">备份目录下并无您的备份文件! </td></tr></table>

<%end if

else

call redata()

end if

end select

%>

<%

'====================压缩数据库 =========================

sub godata()

%>

<table border="1"  cellspacing="0" cellpadding="0" bordercolor=<%=border%> rules=none  width=100% class=3d>

<form action="Admin_data.asp?action=godata" method="post">

<tr>

<td class="title" height=22><b>&nbsp;<img src=img/ie.gif border=0 width=15 height=15 align=absMiddle>&nbsp;压缩数据库</b></td>

</tr>

<tr>

<td  height=30>&nbsp;数据库文件:<input type="text" name="dbpath" value="<%=ACCESSPATH%>" class=yecao>&nbsp;

<input type="checkbox" name="boolIs97" value="True">如果使用 Access 97 数据库请选择

(默认为 Access 2000 数据库)

</td>

</tr><tr><td class="hr"></td></tr>

<tr>

<td class="bg" height=30 align=center>

<input type="submit" value=" " class=adminbutton>

</td>

</tr>

<form>

</table>

<br>

<%

dim dbpath,boolIs97

dbpath = request("dbpath")

boolIs97 = request("boolIs97")

 

If dbpath <> "" Then

dbpath = server.mappath(dbpath)

       response.write(CompactDB(dbpath,boolIs97))

End If

 

end sub

 

'=====================压缩参数=========================

Function CompactDB(dbPath, boolIs97)

Dim fso, Engine, strDBPath,JET_3X

strDBPath = left(dbPath,instrrev(DBPath,"\"))

Set fso = CreateObject("Scripting.FileSystemObject")

 

If fso.FileExists(dbPath) Then

       fso.CopyFile dbpath,strDBPath & "temp.mdb"

       Set Engine = CreateObject("JRO.JetEngine")

 

       If boolIs97 = "True" Then

              Engine.CompactDatabase "Provider=Microsoft.Jet.OLEDB.4.0;jet oledb:database Password=" &"cqs2008"&";Data Source=" & strDBPath & "temp.mdb", _

              "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDBPath & "temp1.mdb;" _

              & "Jet OLEDB:Engine Type=" & JET_3X

       Else

              Engine.CompactDatabase "Provider=Microsoft.Jet.OLEDB.4.0;jet oledb:database Password=" &"cqs2008"&";Data Source=" & strDBPath & "temp.mdb", _

              "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDBPath & "temp1.mdb"

       End If

 

fso.CopyFile strDBPath & "temp1.mdb",dbpath

fso.DeleteFile(strDBPath & "temp.mdb")

fso.DeleteFile(strDBPath & "temp1.mdb")

Set fso = nothing

Set Engine = nothing%>

<table border="1"  cellspacing="1" cellpadding="2" bordercolor=<%=border%>  width=100% class=3d>

<tr>

<td class="bg" height=30 align=center>

<%

CompactDB = "你的数据库【" & dbpath & "】已经压缩成功!" & vbCrLf

%>

<%Else%>

数据库名称或路径不正确. 请重试!

<%End If

End Function

%>

</td>

</tr>

</table>

<%sub backdata()%>

<table border="1"  cellspacing="0" cellpadding="0" bordercolor=<%=border%> rules=none  width=100% class=3d>

<tr>

<td class="title" height=22><b>&nbsp;<img src=img/ie.gif border=0 width=15 height=15 align=absMiddle>&nbsp;备份数据库</b></td>

</tr>

<form method="post" action="Admin_data.asp?action=backdata&act=Backup">

<tr><td height=25 class=bg>

&nbsp;当前数据库路径(相对路径)<input type=text size=25 class=yecao name=DBpath value="<%=ACCESSPATH%>"></td></tr>

<tr><td height=25>

&nbsp;备份数据库目录(相对路径)<input type=text size=25 class=yecao name=bkfolder value="backdata">

&nbsp;如目录不存在,程序将自动创建</td></tr>

<tr><td height=25>

&nbsp;备份数据库名称(填写名称)<input type=text size=25 class=yecao name=bkDBname value=yecao.mdb>

&nbsp;如备份目录有该文件,将覆盖,如没有,将自动创建</td></tr><tr><td class="hr"></td></tr>

<tr><td height=30 class=bg align=center>

&nbsp;<input type=submit value=" " class=adminbutton></td></tr></form></table>

<%end sub

sub updata()

        dim Dbpath,bkfolder,bkdbname,fso

              Dbpath=request.form("Dbpath")

              Dbpath=server.mappath(Dbpath)

              bkfolder=request.form("bkfolder")

              bkdbname=request.form("bkdbname")

              Set Fso=server.createobject("scripting.filesystemobject")

              if fso.fileexists(dbpath) then

                     If CheckDir(bkfolder) = True Then

                     fso.copyfile dbpath,bkfolder& "\"& bkdbname

                     else

                     MakeNewsDir bkfolder

                     fso.copyfile dbpath,bkfolder& "\"& bkdbname

                     end if%>

<table width="100%" align="center" border="1" cellspacing="0" cellpadding="0" bordercolor=<%=border%> class=3d>

<tr><td class=title height=22><b>&nbsp;<img src=img/ie.gif border=0 width=15 height=15 align=absMiddle>&nbsp;备份成功!</b></td></tr>

<tr height=100 class=bg><td align="center">

恭喜恭喜!<br>

备份数据库成功,您备份的数据库路径为<%=bkfolder%>\<%=bkdbname%>

</td></tr></table>

<%Else%>

<table width="100%" align="center" border="1" cellspacing="0" cellpadding="0" bordercolor=<%=border%> class=3d>

<tr><td class=title height=22><b>&nbsp;<img src=img/ie.gif border=0 width=15 height=15 align=absMiddle>&nbsp;备份失败!</b></td></tr>

<tr height=100 class=bg><td align="center">

找不到您所需要备份的文件!

</td></tr></table>

<%End if

end sub

'------------------检查某一目录是否存在-------------------

Function CheckDir(FolderPath)

    dim fso1

       folderpath=Server.MapPath(".")&"\"&folderpath

    Set fso1 = CreateObject("Scripting.FileSystemObject")

    If fso1.FolderExists(FolderPath) then

       '存在

       CheckDir = True

    Else

       '不存在

       CheckDir = False

    End if

    Set fso1 = nothing

End Function

'-------------根据指定名称生成目录-----------------------

Function MakeNewsDir(foldername)

       dim f,fso1

    Set fso1 = CreateObject("Scripting.FileSystemObject")

        Set f = fso1.CreateFolder(foldername)

        MakeNewsDir = True

    Set fso1 = nothing

End Function

%>

<%

'====================恢复数据库=========================

sub redata()

%>

<table border="1"  cellspacing="0" cellpadding="0" bordercolor=<%=border%> rules=none  width=100% class=3d>

<tr>

<td class="title" height=22><b>&nbsp;<img src=img/ie.gif border=0 width=15 height=15 align=absMiddle>&nbsp;恢复数据库</b>

</td></tr>

<form method="post" action="ADMIN_data.asp?action=redata&act=data">

<tr><td height=25>

&nbsp;备份数据库路径(相对)<input type=text size=40 name=DBpath value="<%=BACKACCESSPATH%>" class=yecao></td></tr>

<tr><td height=25>

&nbsp;目标数据库路径(相对)<input type=text size=40 name=backpath value="<%=ACCESSPATH%>" class=yecao></td></tr><tr><td class="hr"></td></tr>

<tr><td height=30 align=center class=bg>

&nbsp;<input type=submit value=" " class=adminbutton>

</td></tr></form></table>

<%end sub%>

 

  评论这张
 
阅读(1191)| 评论(2)
推荐 转载

历史上的今天

在LOFTER的更多文章

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017