HEAD>
Select operation: backup label>
Restore label>
Database Name: >>>>>>>>
File Path: (Backup or Recovered File Path)
form>
<%
Backup and recovery of the 'SQL Server database!
'海娃
'http://www.51windows.net
DIM SQLSERVER, SQLNAME, SQLPassword, Sqllogintimeout, DatabaseName, Bak_File, ACT
SQLServer = "localhost" 'SQL server
SQLNAME = "SA" 'User Name
Sqlpassword = "sa" "password
SQLLogintimeout = 15 'login timeout
DatabaseName = Trim (Request ("DatabaseName"))
BAK_FILE = Trim (Request ("Bak_File"))
Bak_file = replace (Bak_File, "$ 1", DatabaseName)
ACT = LCase (Request ("ACT"))
If DatabaseName = "" ""
Response.write "Input Database Name"
Else
if ACT = "Backup" THEN
Set srv = server.createObject ("sqldmo.sqlserver")
Srv.logintimeout = SQLLogintimeout
Srv.connect SQLServer, Sqlname, SqlpasswordSet Bak = Server.createObject ("SqldMo.Backup")
Bak.Database = DatabaseName
Bak.devices = files
Bak.files = BAK_FILE
Bak.sqlbackup SRV
IF err.number> 0 THEN
Response.write Err.Number & " "
Response.write Err.Description & " font>"
END IF
Response.write " backup success! Font>"
Elseif Act = "restore" THEN
'When you recover, you should do it when you use the database!
SRV.Connect SQLServer, Sqlname, SQLPassword
SET REST = Server.createObject ("SqldMo.Restore")
REST.ACTION = 0 'Full DB Restore
REST.DATABASE = DatabaseName
REST.DEVICES = Files
REST.FILES = BAK_FILE
REST.REPLACEDATABASE = True 'Force Restore over Existing Database
REST.SQLRESTORE SRV
Response.write " Restore success! Font>"
Response.write " No choice operation font>"
%>
Body>
Html>