Export (0) Print
Expand All

SqlDependency.Start Method (String, String)

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)

[<HostProtectionAttribute(SecurityAction.LinkDemand, ExternalThreading = true)>]
static member Start : 
        connectionString:string * 
        queue:string -> bool

Parameters

connectionString
Type: System.String

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

queue
Type: System.String

An existing SQL Server Service Broker queue to be used. If a null reference (Nothing in Visual Basic), the default queue is used.

Return Value

Type: System.Boolean
true if the listener initialized successfully; false if a compatible listener already exists.

ExceptionCondition
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 the CLR.

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.

For additional remarks, see Start.

NoteNote

The HostProtectionAttribute attribute applied to this type or member has the following Resources property value: ExternalThreading. The HostProtectionAttribute does not affect desktop applications (which are typically started by double-clicking an icon, typing a command, or entering a URL in a browser). For more information, see the HostProtectionAttribute class or SQL Server Programming and Host Protection Attributes.

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

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

Show:
© 2014 Microsoft