[vb]代码库
Private objSQLServer As New SQLDMO.SQLServer
Private Sub cmdBackup_Click()
Dim objBackup As New SQLDMO.backup
objBackup.Database = "pubs"
objBackup.MediaName = "C:\Mssql7\Backup\pubs.bak"
'If you backup to tape, you can use
'objBackup.MediaName = "\\.\TAPE0"
objBackup.MediaDescription = "Back of pubs"
objBackup.SQLBackup (objSQLServer)
End Sub
Private Sub cmdRestore_Click()
Dim objRestore As New SQLDMO.Restore
objRestore.Database = "pubs"
objRestore.MediaName = "C:\Mssql7\Backup\pubs.bak"
objRestore.ReplaceDatabase = True
objRestore.SQLRestore (objSQLServer)
End Sub
Private Sub Form_Load()
objSQLServer.Connect "Localhost", "sa", ""
End Sub