SqlDependency 构造函数
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
创建类的新实例 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对象已为其Notification属性分配了一个SqlNotificationRequest对象,并且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对象已为其Notification属性分配了一个SqlNotificationRequest对象,该SqlNotificationRequest对象未与此依赖项关联。
尝试从 SQLCLR 中创建 SqlDependency 实例。
注解
只有满足下列特定要求的 SELECT 语句才支持查询通知。 有关详细信息,请参阅 SQL Server Service Broker 和 使用查询通知。