日期:2014-05-17  浏览次数:21187 次

如何将数据库备份至我的硬盘呀,从我的硬盘恢复大概是不太好实现吧?并且代码已有没听简单的,大家帮下



修改红色部分的吧?

从我的硬盘恢复大概是不太好实现吧?如果能实现的话给出下思路和方向,有代码最好?


<%  

'*****************************************

function CopyTo(ByVal cFile,ByVal toFile)

  cFile=Server.MapPath(cFile) '所要备份的文件

toFile=Server.MapPath(toFile) '备份文件

Dim cFso,cf

set cFso=Server.CreateObject("Scripting.FileSystemObject")

cFso.fileexists(cFile)

  cFso.Copyfile cFile,toFile

end function

'*********************************************

'ASP实现备份及恢复ACCESS数据库操作

'本页面为 databackup.asp

dim dbpath,bkfolder,bkdbname,fso,fso1

  call main()

  call main2()

  'conn.close

  ' set conn=nothing

sub main()

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

call backupdata()

else

%>

  <table cellspacing=1 cellpadding=1 align=center width="90%">  

  <tr>

  <th height=25 >

  &nbsp;&nbsp;<B>数据库备份</B>

  </th>

  </tr>

  <form method="post" action="databackup.asp?action=Backup">

  <tr>

  <td height=100 style="line-height:150%">

  &nbsp;&nbsp;

  当前数据库路径(相对路径):

  <input type=text size=15 name=DBpath value="../data/account.mdb"><BR>

  &nbsp;&nbsp; 备份数据库目录(相对路径):

  <input type=text size=15 name=bkfolder value=../Databackup>&nbsp;如目录不存在,程序将自动创建<BR>

&nbsp;&nbsp; 备份数据库名称(填写名称):  

  <input type=text size=15 name=bkDBname value=database.mdb> &nbsp;如备份目录有该文件,将覆盖,如没有,将自动创建<BR>

  &nbsp;&nbsp;<input type=submit value="备份数据"><hr align="center" width="90%" color="#999999"></td>

  </tr>

  </form>

  </table>

  <%

end if

end sub

sub main2()

if request("action")="Restore" then

Dbpath=request.form("Dbpath")

backpath=request.form("backpath")

if dbpath="" then

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

else

Dbpath=server.mappath(Dbpath)

end if

backpath=server.mappath(backpath)

Response.write Backpath

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

if fso.fileexists(dbpath) then  

  fso.copyfile Dbpath,Backpath

  response.write "<font color=red>成功恢复数据!</font>"

else

  response.write "<font color=red>备份目录下并无您的备份文件!</font>"

end if

else

%>

  <table align=center cellspacing=1 cellpadding=1 width="90%">  

  <tr>

  <th height=25 >

  &nbsp;&nbsp;<B>恢复数据库</B> </th>
  </tr>

  <form method="post" action="databackup.asp?action=Restore">

  <tr>