SqlDependency 建構函式

定義

建立 SqlDependency 類別的新執行個體。

多載

SqlDependency()

以預設設定建立 SqlDependency 類別的新執行個體。

SqlDependency(SqlCommand)

建立 SqlDependency 類別的新執行個體,並使它與 SqlCommand 參數產生關聯。

SqlDependency(SqlCommand, String, Int32)

建立 SqlDependency 類別的新執行個體、使它與 SqlCommand 參數產生關聯,並指定告知選項和逾時值。

SqlDependency()

以預設設定建立 SqlDependency 類別的新執行個體。

public:
 SqlDependency();
public SqlDependency ();
Public Sub New ()

備註

建構函式會使用預設的 Service Broker 服務名稱和逾時,初始化 SqlDependency 物件。在建構之後的某些時間點,您必須使用 方法, AddCommandDependency 將一或多個命令與這個 SqlDependency 物件產生關聯。

只有符合一組特定需求的 SELECT 陳述式才支援查詢通知。 如需詳細資訊,請參閱SQL Server Service Broker使用查詢通知

另請參閱

適用於

SqlDependency(SqlCommand)

建立 SqlDependency 類別的新執行個體,並使它與 SqlCommand 參數產生關聯。

public:
 SqlDependency(System::Data::SqlClient::SqlCommand ^ command);
public SqlDependency (System.Data.SqlClient.SqlCommand command);
new System.Data.SqlClient.SqlDependency : System.Data.SqlClient.SqlCommand -> System.Data.SqlClient.SqlDependency
Public Sub New (command As SqlCommand)

參數

command
SqlCommand

與這個 SqlCommand 物件產生關聯的 SqlDependency 物件。 建構函式會設定 SqlNotificationRequest 物件,並將它繫結至命令。

例外狀況

command 參數為 NULL。

SqlCommand 物件的 SqlNotificationRequest 屬性已指定 Notification 物件,但該 SqlNotificationRequest 與這個相依性沒有關聯。

備註

在內部,此建構函式會建立 類別的 SqlNotificationRequest 實例,並將它系結至 SqlCommand 物件。

只有符合一組特定需求的 SELECT 陳述式才支援查詢通知。 如需詳細資訊,請參閱SQL Server Service Broker使用查詢通知

另請參閱

適用於

SqlDependency(SqlCommand, String, Int32)

建立 SqlDependency 類別的新執行個體、使它與 SqlCommand 參數產生關聯,並指定告知選項和逾時值。

public:
 SqlDependency(System::Data::SqlClient::SqlCommand ^ command, System::String ^ options, int timeout);
public SqlDependency (System.Data.SqlClient.SqlCommand command, string options, int timeout);
new System.Data.SqlClient.SqlDependency : System.Data.SqlClient.SqlCommand * string * int -> System.Data.SqlClient.SqlDependency
Public Sub New (command As SqlCommand, options As String, timeout As Integer)

參數

command
SqlCommand

與這個 SqlCommand 物件產生關聯的 SqlDependency 物件。 建構函式會設定 SqlNotificationRequest 物件,並將它繫結至命令。

options
String

這個相依性所要使用的告知要求選項。 null 以使用預設服務。

timeout
Int32

這個告知的逾時 (以秒為單位)。 預設值為 0,表示應使用伺服器的逾時。

例外狀況

command 參數為 NULL。

逾時值小於零。

SqlCommand 物件的 SqlNotificationRequest 屬性已指定 Notification 物件,但該 SqlNotificationRequest 與這個相依性沒有關聯。

嘗試從 SQLCLR 內建立 SqlDependency 執行個體。

備註

只有符合一組特定需求的 SELECT 陳述式才支援查詢通知。 如需詳細資訊,請參閱SQL Server Service Broker使用查詢通知

另請參閱

適用於