SqlDependency 建構函式
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
建立一個新的類別實例 SqlDependency 。
多載
| 名稱 | Description |
|---|---|
| SqlDependency() |
建立一個新的類別實例 SqlDependency ,並維持預設設定。 |
| SqlDependency(SqlCommand) |
建立一個新的類別實例 SqlDependency ,並將其與 SqlCommand 參數關聯。 |
| SqlDependency(SqlCommand, String, Int32) |
建立一個新的類別實例 SqlDependency ,將其與 SqlCommand 參數關聯,並指定通知選項及逾時值。 |
SqlDependency()
建立一個新的類別實例 SqlDependency ,並維持預設設定。
public:
SqlDependency();
public SqlDependency();
Public Sub New ()
備註
建構子會使用預設的服務代理服務名稱和逾時來初始化物件 SqlDependency 。在建構完成後,你必須使用該 AddCommandDependency 方法將一個或多個指令關聯到這個 SqlDependency 物件。
只有符合特定需求的SELECT語句才支持查詢通知。 欲了解更多資訊,請參閱 SQL Server Service Broker 及 Working with Query Notifications。
另請參閱
適用於
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 及 Working with Query Notifications。
另請參閱
適用於
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 及 Working with Query Notifications。