Share via


Instance.Enable Method

インスタンスの状態を "有効" に設定します。

名前空間: Microsoft.SqlServer.Management.Nmo
アセンブリ: Microsoft.SqlServer.Smo (microsoft.sqlserver.smo.dll 内)

構文

'宣言
Public Sub Enable
public void Enable ()
public:
void Enable ()
public void Enable ()
public function Enable ()

解説

Notification Services インスタンスは、作成時には無効になっています。インスタンスを有効にすると、イベント コレクション、通知の生成、通知の配信、およびサブスクリプション管理を可能にするインスタンスおよびアプリケーション コンポーネントがすべて有効になります。

Notification Services エンジンは、コンポーネントの状態を確認するために、30 秒ごとにデータベースのクエリを実行します。エンジンが状態の変更を取得するまで、エンジン コンポーネントの状態は "有効化中" と表示されます。

使用例

次の例は、Notification Services のインスタンスを作成、登録、および有効にする方法を示しています。

// Set Database Engine instance and 
// Notification Services object
server = new smo.Server(sqlServer);
notificationServices = server.NotificationServices;

// Determine if the instance already exists. If so, exit.
if (server.NotificationServices.Instances.Contains(
    instanceName))
{
    Console.WriteLine("Instance exists and will be deleted.");
    myInstance = notificationServices.Instances[instanceName];
    DeleteInstance(myInstance);
}

// Call ConfigureInstance method to configure the instance
// and define the application(s).
myInstance = ConfigureInstance(notificationServices);

// Create the instance
Console.WriteLine("Creating instance...");
myInstance.Create();

//Optional: Export an Instance Configuration File (ICF)
Console.WriteLine("Exporting ICF...");
myInstance.Export(@"C:\NS\Full", true);

// Register and enable the instance
Console.WriteLine("Registering instance...");
myInstance.RegisterLocal(serviceUserName, servicePassword);
Console.WriteLine("Enabling instance...");
myInstance.Enable();
Console.WriteLine("Done.");
' Set Database Engine server and 
' Notification Services object
server = New smo.Server(sqlServer)
notificationServices = server.NotificationServices

' Determine if the instance already exists. If so, exit.
If server.NotificationServices.Instances.Contains( _
  instanceName) Then
    Console.WriteLine( _
        "Instance exists and will be deleted.")
    myInstance = notificationServices.Instances( _
        instanceName)
    DeleteInstance(myInstance)
End If

' Call ConfigureInstance method to configure the instance
' and define the application(s).
myInstance = ConfigureInstance(notificationServices)

' Create the instance
Console.WriteLine("Creating instance...")
myInstance.Create()

'Optional: Export an Instance Configuration File (ICF)
Console.WriteLine("Exporting ICF...")
myInstance.Export("C:\NS\Full", True)

' Register and enable the instance
Console.WriteLine("Registering instance...")
myInstance.RegisterLocal(serviceUserName, servicePassword)
Console.WriteLine("Enabling instance...")
myInstance.Enable()
Console.WriteLine("Done.")

スレッド セーフ

この型の public static (Microsoft Visual Basic では共有 ) メンバは、スレッド セーフです。インスタンス メンバの場合は、スレッド セーフであるとは限りません。

プラットフォーム

開発プラットフォーム

サポートされているプラットフォームの一覧については、「SQL Server 2005 のインストールに必要なハードウェアおよびソフトウェア」を参照してください。

対象プラットフォーム

サポートされているプラットフォームの一覧については、「SQL Server 2005 のインストールに必要なハードウェアおよびソフトウェア」を参照してください。

参照

関連項目

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

その他の技術情報

インスタンス、アプリケーション、またはコンポーネントの有効化および無効化
インスタンス、アプリケーション、およびコンポーネントの状態表示