SQL Server可以使用SQL-DMO来做:
恢复数据库:
Private Sub Command2_Click()
Dim sFile As String
sFile = "N_1"
Dim oServer As New SQLDMO.SQLServer
Dim oDatabase As New SQLDMO.Database
Dim oRestore As New SQLDMO.Restore
oServer.Connect servername, username, password
With oRestore
.Files = sFile
.Database = "Northwind"
.ReplaceDatabase = True
.SQLRestore oServer
End With
Set oRestore = Nothing
Set oDatabase = Nothing
oServer.DisConnect
Set oServer = Nothing
MsgBox ("OK")
End Sub备份:
Dim oBackup As New SQLDMO.Backup
oBackup.Action = SQLDMOBackup_Database
oBackup.Database = "Northwind"
oBackup.Devices = "[NorthDev1],[NorthDev2]"
oBackup.BackupSetName = "Northwind_Full"
oBackup.BackupSetDescription = "Full backup of Northwind sample."oBackup.SQLBackup oSQLServer
恢复数据库:
Private Sub Command2_Click()
Dim sFile As String
sFile = "N_1"
Dim oServer As New SQLDMO.SQLServer
Dim oDatabase As New SQLDMO.Database
Dim oRestore As New SQLDMO.Restore
oServer.Connect servername, username, password
With oRestore
.Files = sFile
.Database = "Northwind"
.ReplaceDatabase = True
.SQLRestore oServer
End With
Set oRestore = Nothing
Set oDatabase = Nothing
oServer.DisConnect
Set oServer = Nothing
MsgBox ("OK")
End Sub备份:
Dim oBackup As New SQLDMO.Backup
oBackup.Action = SQLDMOBackup_Database
oBackup.Database = "Northwind"
oBackup.Devices = "[NorthDev1],[NorthDev2]"
oBackup.BackupSetName = "Northwind_Full"
oBackup.BackupSetDescription = "Full backup of Northwind sample."oBackup.SQLBackup oSQLServer
好象没有这一个对象!sqldmo