Поделиться через


Instance.Update Method

Updates the instance of Notifications, and all of its applications, with changes made to Instance and Application properties.

Пространство имен: Microsoft.SqlServer.Management.Nmo
Сборка: Microsoft.SqlServer.Smo (in microsoft.sqlserver.smo.dll)

Синтаксис

'Декларация
Public Sub Update
public void Update ()
public:
void Update ()
public void Update ()
public function Update ()

Замечания

The Update method compares the current instance and application definitions in the databases with your definitions of the instance and its applications. For each valid change, the Update method updates the database as specified.

Not all of the instance and application properties can be updated. For example you cannot change the instance and application database definitions. For more information, review the documentation for the properties you are updating.

Altering some EventClass, SubscriptionClass, and NotificationClass properties can delete or rename existing tables in the application database. Review the properties you are changing to make sure you know the effects of the changes.

Пример

The following examples show how to update an instance of Notification Services:

// Specify the Database Engine instance that hosts the 
// Notificaiton Services instance and get a reference to 
// the NotificationServices object.
smo.Server server = new smo.Server(sqlServer);
NotificationServices notificationServices = 
    server.NotificationServices;

// Get the Notification Services instance.
Instance nsinst = notificationServices.Instances[instanceName];

// If using encryption, set the argument key. The value
// must match the value used when creating the instance.
nsinst.ArgumentKey = "MyKey135711";

// Disable the instance.
Console.WriteLine("Disabling instance...");
nsinst.Disable();

// Get the application to update.
Application nsapp = nsinst.Applications[applicationName];

// Set the application's subscription throttle to 1000.
nsapp.SubscriptionThrottle = 1000;

// Update the instance of Notification Services.
// This can take a few minutes.
Console.WriteLine("Updating instance...");
nsinst.Update();

// Enable the instance.
Console.WriteLine("Enabling instance...");
nsinst.Enable();

// Generate new XML files.
Console.WriteLine("Exporting instance configuration...");
nsinst.Export(@"C:\NS\Full", true);
Console.WriteLine("Done.");
' Specify the Database Engine instance that hosts the 
' Notificaiton Services instance and get a reference to 
' the NotificationServices object.
Dim server As smo.Server = New smo.Server(sqlServer)
Dim notificationServices As NotificationServices = _
    server.NotificationServices

' Get the Notification Services instance.
Dim nsinst As Instance = _
    notificationServices.Instances(instanceName)

' If using encryption, set the argument key. The value
' must match the value used when creating the instance.
nsinst.ArgumentKey = "MyKey135711"

' Disable the instance.
Console.WriteLine("Disabling instance...")
nsinst.Disable()

' Get the application to update.
Dim nsapp As Application = nsinst.Applications(applicationName)

' Set the application's subscription throttle to 1000.
nsapp.SubscriptionThrottle = 1000

' Update the instance of Notification Services.
' This can take a few minutes.
Console.WriteLine("Updating instance...")
nsinst.Update()

' Enable the instance.
Console.WriteLine("Enabling instance...")
nsinst.Enable()

' Verify the change in XML (just for fun).
Console.WriteLine("Exporting instance configuration...")
nsinst.Export("C:\NS\Full\Update", True)
Console.WriteLine("Done.")

Синхронизация потоков

Any public static (Shared in Microsoft Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Платформы

Платформы разработки

Список поддерживаемых платформ см. в разделе Hardware and Software Requirements for Installing SQL Server 2005.

Целевые платформы

Список поддерживаемых платформ см. в разделе Hardware and Software Requirements for Installing SQL Server 2005.

См. также

Справочник

Instance Class
Instance Members
Microsoft.SqlServer.Management.Nmo Namespace

Другие ресурсы

Обновление экземпляров и приложений
Команда nscontrol update