首页 | 心情日记 | 建站心得 | 编程技术 | 大盘分析 | 股市信息 | 学习园地 | 电脑技巧 | 物流外贸 | 另类其它 | 站长推荐 | 给我留言 | 相册

用户登陆
用户:
密码:
 
不保存保存一天
保存一月保存一年

站点日历
73 2024 - 4 48
 123456
78910111213
14151617181920
21222324252627
282930


站点统计

最新评论

日志搜索

 标题   内容


网站启用临时IP与永久IP黑名单技术 关于IIS发生意外错误0x8ffe2740
未知 ASP数据库恢复代码   [ 日期:2010-03-19 20:01:40 ]   [ 来自:本站原创 ]

海外邮件中继,海外退信中继,美国高速VPS,不限流量VPN,邮局维护和管理,邮件网关,EMOS邮件中继,POSTFIX邮件中继,Winwebmail邮件中继,Winmail邮件中继,DBMail邮件中继,JDMail邮件中继,Exchange邮件中继,MDaemon邮件中继 淘宝店:http://shantan.taobao.com 云邮科技官网:www.yunrelay.com

【字体设置:
今天在百度知道那里有人问到了我关于数据库恢复的问题,说他的代码总是出现错误,于是我就整理了一下,弄了一个单文件形式的数据库恢复代码:

代码使用非常的简单,把以下的代码单独保存为一个文件restore.asp,修改一下你的数据库的路径即可,然后在输入框内输入你的备份数据库的相对路径即可恢复了。当然,还需要组件的支撑,检测的程序我也一起放上去了。

<%'连接数据库
DBName="Data/mydata.mdb"
Set conn = Server.CreateObject("ADODB.Connection")
connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(DBName)
conn.Open connstr
%>
<%'恢复数据函数
sub RestoreData()
 dim backpath,fso
 backpath=request.form("backpath")
 backpath=server.mappath(backpath)
 if dbpath="" then
  response.write "请输入您要恢复成的数据库全名" 
 end if
 Set Fso=server.createobject("scripting.filesystemobject")
 if fso.fileexists(dbpath) then       
  fso.copyfile Backpath,Dbpath
  response.write "<a href=javascript:history.back(-1)>成功恢复数据=====点击返回上一页</a>"
 else
  response.write "备份目录下并无您的备份文件!" 
 end if
end sub
%>
<%
'***************************************************
'函数名:IsObjInstalled
'作  用:检查组件是否已经安装
'参  数:strClassString ----组件名
'返回值:True  ----已经安装
'       False ----没有安装
'***************************************************
Function IsObjInstalled(strClassString)
 On Error Resume Next
 IsObjInstalled = False
 Err = 0
 Dim xTestObj
 Set xTestObj = Server.CreateObject(strClassString)
 If 0 = Err Then IsObjInstalled = True
 Set xTestObj = Nothing
 Err = 0
End Function
%>
<%
dim dbpath
dim ObjInstalled
dbpath=server.mappath(DBName)
ObjInstalled=IsObjInstalled("Scripting.FileSystemObject")
Conn.Close
%>
<script language=JavaScript>  
function check(theform)                     
{                        
                                     
    if (theform.backpath.value.length<5)                      
    {                     
        alert("备份数据库路径不能为空");                        
        theform.backpath.focus();                      
         return(false);                         
    }
 }
</script> 
          <tr align="center"> 
            <td height="40"><form name="form2" method="post" action="restore.asp?action=Restore" onsubmit="return check(this);">
        <%
if request("action")="Restore" then
 call RestoreData()
else
%>备份数据库路径(相对):<input name=backpath type=text id="backpath" value="" size=50 maxlength="200"><input name="submit" 

type=submit value=" 恢复数据"></td>
          </tr>
        </table>
<%
end if
%></td>
 </tr>

暂时没有评论
   发表评论 - 不要忘了输入验证码哦!
作者: 用户:  密码:  我要注册 验证码: 
为防止广告注册机程序,验证码不会自动显示,请点击此处显示或者(刷新)验证码!
评论:

禁止表情
禁止UBB
禁止图片
识别链接
识别关键字
确定发布?
最多可以输入200个字,目前你已经输入了0个字;你今日还可以发表10条评论!
 
   

CopyRight © 2008-2010 广东金融学院030904班 All Rights Reserved
Powered by www.030904.com