濮阳杆衣贸易有限公司

主頁(yè) > 知識(shí)庫(kù) > asp 在線備份與恢復(fù)sqlserver數(shù)據(jù)庫(kù)的代碼

asp 在線備份與恢復(fù)sqlserver數(shù)據(jù)庫(kù)的代碼

熱門標(biāo)簽:創(chuàng)意電話機(jī)器人 武穴地圖標(biāo)注 外呼線路批發(fā) java外呼系統(tǒng)是什么 地圖標(biāo)注陽(yáng)江 梧州市地圖標(biāo)注 世界地圖標(biāo)注了哪些城市 石家莊慧營(yíng)銷外呼系統(tǒng) 濟(jì)源電銷外呼系統(tǒng)線路
asp在線備份sql server數(shù)據(jù)庫(kù):
1、備份sqlserver
復(fù)制代碼 代碼如下:

%
SQL="backup database 數(shù)據(jù)庫(kù)名 to disk='"Server.MapPath("backup")"\""backuptext.dat""'"
set cnn=Server.createobject("adodb.connection")
cnn.open "driver={SQL Server};Server=服務(wù)器名;uid=sa;pwd="
cnn.execute SQL
on error resume next
if err>0 then
response.wrITe "錯(cuò)誤:"err.Descripting
else
response.wrITe "數(shù)據(jù)備份成功!"
end if
%>

2、恢復(fù)sqlserver
復(fù)制代碼 代碼如下:

%
SQL="Restore database 數(shù)據(jù)庫(kù)名 from disk='"Server.MapPath("backup")"\""backuptext.dat""'"
set cnn=Server.createobject("adodb.connection")
cnn.open "driver={SQL Server};Server=服務(wù)器名;uid=sa;pwd="
cnn.execute SQL
on error resume next
if err>0 then
response.wrITe "錯(cuò)誤:"err.Descripting
else
response.wrITe "數(shù)據(jù)恢復(fù)成功!"
end if
%>

ACCESS原理一樣
復(fù)制代碼 代碼如下:

%
'*****************************************
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實(shí)現(xiàn)備份及恢復(fù)ACCESS數(shù)據(jù)庫(kù)操作
'本頁(yè)面為 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>數(shù)據(jù)庫(kù)備份/B>
/th>
/tr>
form method="post" action="databackup.asp?action=Backup">
tr>
td height=100 style="line-height:150%">
nbsp;nbsp;
當(dāng)前數(shù)據(jù)庫(kù)路徑(相對(duì)路徑):
input type=text size=15 name=DBpath value="../mdb/database.mdb">BR>
nbsp;nbsp; 備份數(shù)據(jù)庫(kù)目錄(相對(duì)路徑):
input type=text size=15 name=bkfolder value=../Databackup>nbsp;如目錄不存在,程序?qū)⒆詣?dòng)創(chuàng)建BR>
nbsp;nbsp; 備份數(shù)據(jù)庫(kù)名稱(填寫名稱):
input type=text size=15 name=bkDBname value=database.mdb> nbsp;如備份目錄有該

文件,將覆蓋,如沒有,將自動(dòng)創(chuàng)建BR>
nbsp;nbsp;input type=submIT value="備份數(shù)據(jù)">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 "請(qǐng)輸入您要恢復(fù)成的數(shù)據(jù)庫(kù)全名"
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>成功恢復(fù)數(shù)據(jù)!/font>"
else
response.wrITe "font color=red>備份目錄下并無(wú)您的備份文件!/font>"
end if
else
%>
table align=center cellspacing=1 cellpadding=1 width="90%">
tr>
th height=25 >
nbsp;nbsp;B>恢復(fù)數(shù)據(jù)庫(kù)/B>
/th>
/tr>
form method="post" action="databackup.asp?action=Restore">
tr>
td height=100 >
nbsp;nbsp;備份數(shù)據(jù)庫(kù)路徑(相對(duì)):
input type=text size=30 name=DBpath value="../Databackup/database.mdb">nbsp;nbsp;BR>
nbsp;nbsp;當(dāng)前數(shù)據(jù)庫(kù)路徑(相對(duì)):
input type=text size=30 name=backpath value="../mdb/database.mdb">BR>
nbsp;nbsp;input type=submIT value="恢復(fù)數(shù)據(jù)"> hr width="90%" align="center" color="#999999">
nbsp;nbsp;font color="#666666">·注意:所有路徑都是相對(duì)路徑 nbsp;nbsp;/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>備份數(shù)據(jù)庫(kù)成功,您備份的數(shù)據(jù)庫(kù)路徑為" 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
'-------------根據(jù)指定名稱生成目錄---------
Function MakeNewsDir(foldername)
dim f
Set fso1 = CreateObject("Scripting.FileSystemObject")
Set f = fso1.CreateFolder(foldername)
MakeNewsDir = True
Set fso1 = nothing
End Function
%>
您可能感興趣的文章:
  • SqlServer備份數(shù)據(jù)庫(kù)的4種方式介紹
  • sqlserver備份還原數(shù)據(jù)庫(kù)功能封裝分享
  • sqlserver2005 master與msdb數(shù)據(jù)庫(kù)備份恢復(fù)過程
  • SQLServer 2005 自動(dòng)備份數(shù)據(jù)庫(kù)的方法分享(附圖解教程)
  • Sqlserver2000 數(shù)據(jù)庫(kù)備份實(shí)例代碼
  • sqlserver 自動(dòng)備份所有數(shù)據(jù)庫(kù)的SQL
  • sqlserver 數(shù)據(jù)庫(kù)日志備份和恢復(fù)步驟
  • SqlServer批量備份多個(gè)數(shù)據(jù)庫(kù)且刪除3天前的備份

標(biāo)簽:揭陽(yáng) 迪慶 南寧 淮北 來(lái)賓 唐山 滁州 甘南

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《asp 在線備份與恢復(fù)sqlserver數(shù)據(jù)庫(kù)的代碼》,本文關(guān)鍵詞  asp,在線,備份,與,恢復(fù),sqlserver,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無(wú)關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《asp 在線備份與恢復(fù)sqlserver數(shù)據(jù)庫(kù)的代碼》相關(guān)的同類信息!
  • 本頁(yè)收集關(guān)于asp 在線備份與恢復(fù)sqlserver數(shù)據(jù)庫(kù)的代碼的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    当涂县| 利辛县| 金寨县| 仁布县| 当阳市| 南城县| 屯留县| 宜兴市| 柳河县| 岐山县| 壶关县| 岫岩| 咸阳市| 常熟市| 巴塘县| 涞水县| 黄冈市| 惠来县| 宜城市| 类乌齐县| 文安县| 调兵山市| 宁安市| 东安县| 嘉兴市| 沁水县| 太白县| 沐川县| 金华市| 铜川市| 江西省| 德兴市| 楚雄市| 彭州市| 兴化市| 巫溪县| 建阳市| 醴陵市| 上蔡县| 永城市| 南丹县|