91网首页-91网页版-91网在线观看-91网站免费观看-91网站永久视频-91网站在线播放

LOGO OA教程 ERP教程 模切知識交流 PMS教程 CRM教程 開發文檔 其他文檔  
 
網站管理員

asp 在線備份與恢復sqlserver數據庫的代碼

admin
2010年11月26日 0:38 本文熱度 3157
asp 在線備份 恢復 sql server 數據庫,對于遠程沒有提供sqlserver遠程連接或打包下載的朋友是個臨時解決方法,對于大數據來說可能效果不好。


asp在線備份sql server數據庫:
1、備份sqlserver
復制代碼 代碼如下:
<%
SQL="backup database 數據庫名 to disk='"&Server.MapPath("backup")&"\"&"backuptext.dat"&"'"
set cnn=Server.createobject("adodb.connection")
cnn.open "driver={SQL Server};Server=服務器名;uid=sa;pwd="
cnn.execute SQL
on error resume next
if err<>0 then
response.wrITe "錯誤:"&err.Descripting
else
response.wrITe "數據備份成功!"
end if
%>

 

2、恢復sqlserver
復制代碼 代碼如下:
<%
SQL="Restore database 數據庫名 from disk='"&Server.MapPath("backup")&"\"&"backuptext.dat"&"'"
set cnn=Server.createobject("adodb.connection")
cnn.open "driver={SQL Server};Server=服務器名;uid=sa;pwd="
cnn.execute SQL
on error resume next
if err<>0 then
response.wrITe "錯誤:"&err.Descripting
else
response.wrITe "數據恢復成功!"
end if
%>

 

ACCESS原理一樣
復制代碼 代碼如下:
<%
'*****************************************
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 >
<B>數據庫備份</B>
</th>
</tr>
<form method="post" action="databackup.asp?action=Backup">
<tr>
<td height=100 style="line-height:150%">

當前數據庫路徑(相對路徑):
<input type=text size=15 name=DBpath value="../mdb/database.mdb"><BR>
備份數據庫目錄(相對路徑):
<input type=text size=15 name=bkfolder value=../Databackup> 如目錄不存在,程序將自動創建<BR>
備份數據庫名稱(填寫名稱):
<input type=text size=15 name=bkDBname value=database.mdb> 如備份目錄有該

文件,將覆蓋,如沒有,將自動創建<BR>
<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 >
<B>恢復數據庫</B>
</th>
</tr>
<form method="post" action="databackup.asp?action=Restore">
<tr>
<td height=100 >
備份數據庫路徑(相對):
<input type=text size=30 name=DBpath value="../Databackup/database.mdb"> <BR>
當前數據庫路徑(相對):
<input type=text size=30 name=backpath value="../mdb/database.mdb"><BR>
<input type=submIT value="恢復數據"> <hr width="90%" align="center" color="#999999">
<font color="#666666">·注意:所有路徑都是相對路徑 </font></td>
</tr>
</form>
</table>
<%
end if
end sub
sub backupdata()
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
response.wrITe "<font color=red>備份數據庫成功,您備份的數據庫路徑為" &bkfolder& "\\"& bkdbname+"</font>"
Else
response.wrITe "<font color=red>找不到您所需要備份的文件。</font>"
End if
end sub
'------------------檢查某一目錄是否存在-------------------
Function CheckDir(FolderPath)
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
Set fso1 = CreateObject("Scripting.FileSystemObject")
Set f = fso1.CreateFolder(foldername)
MakeNewsDir = True
Set fso1 = nothing
End Function
%>

該文章在 2010/11/26 0:38:39 編輯過
關鍵字查詢
相關文章
正在查詢...
點晴ERP是一款針對中小制造業的專業生產管理軟件系統,系統成熟度和易用性得到了國內大量中小企業的青睞。
點晴PMS碼頭管理系統主要針對港口碼頭集裝箱與散貨日常運作、調度、堆場、車隊、財務費用、相關報表等業務管理,結合碼頭的業務特點,圍繞調度、堆場作業而開發的。集技術的先進性、管理的有效性于一體,是物流碼頭及其他港口類企業的高效ERP管理信息系統。
點晴WMS倉儲管理系統提供了貨物產品管理,銷售管理,采購管理,倉儲管理,倉庫管理,保質期管理,貨位管理,庫位管理,生產管理,WMS管理系統,標簽打印,條形碼,二維碼管理,批號管理軟件。
點晴免費OA是一款軟件和通用服務都免費,不限功能、不限時間、不限用戶的免費OA協同辦公管理系統。
Copyright 2010-2025 ClickSun All Rights Reserved

主站蜘蛛池模板: 成人h片在线 | 欧美伊人网91| 国产91视频一区 | 欧美日韩精品乱国产 | 国产高清乱理 | 午夜韩日 | 成人爽爽激 | 国产xxxxx | 九九精品视 | 国产色啪a∨在 | 中文字幕人 | 国产伦理一区二区 | 成人精品免费在 | 黑人大战亚洲 | 国产原创剧 | 国产情趣酒店鸳鸯 | 韩国午夜插插 | 日韩理论中文在 | 午夜男女福利 | 岛国精品在线播放 | 国产精品国产高清 | 日本视频在线免费 | 国产高清成免费视频 | 乱子轮熟睡1区 | 日本福利| 国产大片黄在线观 | 海量欧美亚洲色五月 | 国产福利在线观看永 | 国产一区二区香蕉 | 成人国产第一区在 | 日韩有码国产精品 | 日本精品在线看 | 精品三级乱伦免费 | 片专区成人 | 国产亚洲情侣 | 成人免费福利片 | 成人国产经典 | 国产乱叫456在线 | 精品国产午夜肉伦 | 午夜不卡视频 | 日本午夜福利剧场 |