SqlDependency Constructor (SqlCommand, String, Int32)

 

Creates a new instance of the SqlDependency class, associates it with the SqlCommand parameter, and specifies notification options and a time-out value.

Namespace:   System.Data.SqlClient
Assembly:  System.Data (in System.Data.dll)

public SqlDependency(
	SqlCommand command,
	string options,
	int timeout
)

Parameters

command
Type: System.Data.SqlClient.SqlCommand

The SqlCommand object to associate with this SqlDependency object. The constructor sets up a SqlNotificationRequest object and bind it to the command.

options
Type: System.String

The notification request options to be used by this dependency. null to use the default service.

timeout
Type: System.Int32

The time-out for this notification in seconds. The default is 0, indicating that the server's time-out should be used.

Exception Condition
ArgumentNullException

The command parameter is NULL.

ArgumentOutOfRangeException

The time-out value is less than zero.

InvalidOperationException

The SqlCommand object already has a SqlNotificationRequest object assigned to its Notification property and that SqlNotificationRequest is not associated with this dependency.

An attempt was made to create a SqlDependency instance from within SQLCLR.

Query notifications are supported only for SELECT statements that meet a list of specific requirements. The following table provides links to the Service Broker and Query Notifications documentation in SQL Server Books Online.

SQL Server Books Online

.NET Framework
Available since 2.0
Return to top
Show: