System.Data 2.0.0.0 System.Object

is ideal for caching scenarios, where your ASP.NET application or middle-tier service needs to keep certain information cached in memory. allows you to receive notifications when the original data in the database changes so that the cache can be refreshed.

To set up a dependency, you need to associate a object to one or more objects. To receive notifications, you need to subscribe to the event. For more information about the requirements for creating queries for notifications, see "Creating a Query for Notification" in SQL Server Books Online.

was designed to be used in ASP.NET or middle-tier services where there is a relatively small number of servers having dependencies active against the database. It was not designed for use in client applications, where hundreds or thousands of client computers would have objects set up for a single database server. If you are developing an application where you need reliable sub-second notifications when data changes, review the sections Planning an Efficient Query Notifications Strategy and Alternatives to Query Notifications in the Planning for Notifications topic in SQL Server Books Online.

For more information, see Using Query Notifications and "Building Notification Solutions" in SQL Server Books Online.

The event may be generated on a different thread from the thread that initiated command execution.

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

Creating a Query for Notification

Security Considerations for Service Broker

Security and Protection (Service Broker)

Security Considerations for Notifications Services

Query Notification Permissions

International Considerations for Service Broker

Solution Design Considerations (Service Broker)

Service Broker Developer InfoCenter

Developer's Guide (Service Broker)

The object represents a query notification dependency between an application and an instance of SQL Server. An application can create a object and register to receive notifications via the event handler.

- Constructor
  2.0.0.0

  The constructor initializes the object using the default Service Broker service name and time-out. At some point after construction, you must use the method to associate one or more commands to this object.

  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

  Creating a Query for Notification

  Security Considerations for Service Broker

  Security and Protection (Service Broker)

  Security Considerations for Notifications Services

  Query Notification Permissions

  International Considerations for Service Broker

  Solution Design Considerations (Service Broker)

  Service Broker Developer InfoCenter

  Developer's Guide (Service Broker)

  Creates a new instance of the class with the default settings.

- Constructor
  2.0.0.0

  Internally, this constructor creates an instance of the class, and binds it to a object.

  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

  Creating a Query for Notification

  Security Considerations for Service Broker

  Security and Protection (Service Broker)

  Security Considerations for Notifications Services

  Query Notification Permissions

  International Considerations for Service Broker

  Solution Design Considerations (Service Broker)

  Service Broker Developer InfoCenter

  Developer's Guide (Service Broker)

  Creates a new instance of the class and associates it with the parameter.

  The object to associate with this object. The constructor will set up a object and bind it to the command.
- Constructor
  2.0.0.0

  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

  Creating a Query for Notification

  Security Considerations for Service Broker

  Security and Protection (Service Broker)

  Security Considerations for Notifications Services

  Query Notification Permissions

  International Considerations for Service Broker

  Solution Design Considerations (Service Broker)

  Service Broker Developer InfoCenter

  Developer's Guide (Service Broker)

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

  The object to associate with this object. The constructor sets up a object and bind it to the command.
  The notification request options to be used by this dependency. to use the default service.
  The time-out for this notification in seconds. The default is 0, indicating that the server's time-out should be used.
- Method
  2.0.0.0
  System.Void ``

  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

  Creating a Query for Notification

  Security Considerations for Service Broker

  Security and Protection (Service Broker)

  Security Considerations for Notifications Services

  Query Notification Permissions

  International Considerations for Service Broker

  Solution Design Considerations (Service Broker)

  Service Broker Developer InfoCenter

  Developer's Guide (Service Broker)

  Associates a object with this instance.

  A object containing a statement that is valid for notifications.
- Property
  2.0.0.0
  System.Boolean To be added.

  If you are not using the event, you can check the property to determine if the query results have changed.

  The property does not necessarily imply a change in the data. Other circumstances, such as time-out expired and failure to set the notification request, also generate a change event.

  Gets a value that indicates whether one of the result sets associated with the dependency has changed.

- Property
  2.0.0.0
  System.String To be added.

  The property is used to uniquely identify a given instance.

  Gets a value that uniquely identifies this instance of the class.

- Event
  2.0.0.0
  System.Data.SqlClient.OnChangeEventHandler

  occurs when the results for the associated command change. If you are not using , you can check the property to determine whether the query results have changed.

  The event does not necessarily imply a change in the data. Other circumstances, such as time-out expired and failure to set the notification request, also generate .

  Occurs when a notification is received for any of the commands associated with this object.

- Method
  2.0.0.0
  System.Boolean ``

  This method starts the listener for the for receiving dependency notifications from the instance of ssNoVersion specified by the parameter. This method may be called more than once with different connection strings for multiple servers.

  For additional remarks, see .

  Starts the listener for receiving dependency change notifications from the instance of SQL Server specified by the connection string.

  true if the listener initialized successfully; false if a compatible listener already exists.

  The connection string for the instance of ssNoVersion from which to obtain change notifications.
- Method
  2.0.0.0
  System.Boolean `` ``

  This method starts the listener for the for receiving dependency notifications from the instance of SQL Server specified by the parameter. This method may be called more than once with different connection strings for multiple servers.

  If no queue name is specified, creates a temporary queue and service in the server that is used for the entire process, even if the process involves more than one . The queue and service are automatically removed upon application shutdown.

  For additional remarks, see .

  Starts the listener for receiving dependency change notifications from the instance of SQL Server specified by the connection string using the specified SQL Server Service Broker queue.

  true if the listener initialized successfully; false if a compatible listener already exists.

  The connection string for the instance of SQL Server from which to obtain change notifications. An existing SQL Server Service Broker queue to be used. If null, the default queue is used.
- Method
  2.0.0.0
  System.Boolean ``

  The method must be called for each call. A given listener only shuts down fully when it receives the same number of requests as requests.

  Stops a listener for a connection specified in a previous call.

  true if the listener was completely stopped; false if the was unbound from the listener, but there are is at least one other using the same listener.

  Connection string for the instance of SQL Server that was used in a previous call.
- Method
  2.0.0.0
  System.Boolean `` ``

  The method must be called for each call. A given listener only shuts down fully when it receives the same number of requests as requests.

  Stops a listener for a connection specified in a previous call.

  true if the listener was completely stopped; false if the was unbound from the listener, but there is at least one other using the same listener.

  Connection string for the instance of SQL Server that was used in a previous call. The SQL Server Service Broker queue that was used in a previous call.