Imports Microsoft.SqlServer.Management.Smo ? Allow shorthand notation
Module Module1
  Sub Main()
    Dim db As String = «AdventureWorks» ? Define and set a variable
    Dim bck As New Backup() ? Instantiate a Backup object
    bck.Action = BackupActionType.Database ? Set Action property
    bck.BackupSetName = db & «_BackupSet» ? Set BackupSetName property
    bck.Database = db ? Set Database name property
    bck.DeviceType = DeviceType.File ? Set DeviceType property
    ? Add method adds file to Devices collection
    bck.Devices.Add(«C:» + db + «.bak»)
    Dim s2k5 As New Server() ? Instantiate a Server object
    bck.SqlBackup(s2k5) ? Invoke Backup object?s SqlBackup method
  End Sub
End Module

Поделитесь материалом с коллегами и друзьями