Export (0) Print
Expand All

SqlDependency.Start Method (String, String)

Note: This method is new in the .NET Framework version 2.0.

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.

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

public static bool Start (
	string connectionString,
	string queue
)
public static boolean Start (
	String connectionString, 
	String queue
)
public static function Start (
	connectionString : String, 
	queue : String
) : boolean

Parameters

connectionString

The connection string for the instance of SQL Server from which to obtain change notifications.

queue

An existing SQL Server Service Broker queue to be used. If null, the default queue is used.

Return Value

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

Exception typeCondition

ArgumentNullException

The connectionString parameter is NULL.

InvalidOperationException

The connectionString parameter is the same as a previous call to this method, but the parameters are different.

The method was called from within SQLCLR.

SecurityException

The caller does not have the required SqlClientPermission code access security (CAS) permission.

SqlException

A subsequent call to the method has been made with an equivalent connectionString parameter but a different user, or a user that does not default to the same schema.

Also, any underlying SqlClient exceptions.

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

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

Multiple calls to the Start method can be made, subject to the following restrictions:

  • Multiple calls with identical parameters (the same connection string, queue, and Windows credentials in the calling thread) are valid.

  • Multiple calls with different connection strings are valid as long as:

    • Each connection string specifies a different database, or

    • Each connection string specifies a different user, or

    • The calls come from different application domains.

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0

Community Additions

ADD
Show:
© 2014 Microsoft