Sugerir traducción
 
Otros han sugerido:

progress indicator
No hay más sugerencias.
Evaluar y enviar comentarios
Contraer todo/Expandir todo Contraer todo
Ver contenido:  en paraleloVer contenido: en paralelo
.NET Framework Class Library
SqlDependency Class

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

System..::.Object
  System.Data.SqlClient..::.SqlDependency

Namespace:  System.Data.SqlClient
Assembly:  System.Data (in System.Data.dll)
Visual Basic
Public NotInheritable Class SqlDependency
C#
public sealed class SqlDependency
Visual C++
public ref class SqlDependency sealed
F#
[<Sealed>]
type SqlDependency =  class end

The SqlDependency type exposes the following members.

  NameDescription
Public methodSqlDependency()()()Creates a new instance of the SqlDependency class with the default settings.
Public methodSqlDependency(SqlCommand)Creates a new instance of the SqlDependency class and associates it with the SqlCommand parameter.
Public methodSqlDependency(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.
Top
  NameDescription
Public propertyHasChangesGets a value that indicates whether one of the result sets associated with the dependency has changed.
Public propertyIdGets a value that uniquely identifies this instance of the SqlDependency class.
Top
  NameDescription
Public methodAddCommandDependencyAssociates a SqlCommand object with this SqlDependency instance.
Public methodEquals(Object)Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetHashCodeServes as a hash function for a particular type. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodStatic memberStart(String)Starts the listener for receiving dependency change notifications from the instance of SQL Server specified by the connection string.
Public methodStatic memberStart(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.
Public methodStatic memberStop(String)Stops a listener for a connection specified in a previous Start call.
Public methodStatic memberStop(String, String)Stops a listener for a connection specified in a previous Start call.
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Top
  NameDescription
Public eventOnChangeOccurs when a notification is received for any of the commands associated with this SqlDependency object.
Top

SqlDependency is ideal for caching scenarios, where your ASP.NET application or middle-tier service needs to keep certain information cached in memory. SqlDependency 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 SqlDependency object to one or more SqlCommand objects. To receive notifications, you need to subscribe to the OnChange event. For more information about the requirements for creating queries for notifications, see "Creating a Query for Notification" in SQL Server Books Online.

NoteNote

SqlDependency 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 SqlDependency objects set up for a single database server.

SqlDependency requires the .NET Framework version 2.0 and SQL Server 2005. For more information, see Query Notifications in SQL Server (ADO.NET) and "Building Notification Solutions" in SQL Server Books Online.

NoteNote

The OnChange 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.

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role not supported), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Biblioteca de clases de .NET Framework
SqlDependency (Clase)

El objeto SqlDependency representa una dependencia de notificación de consulta entre una aplicación y una instancia de SQL Server 2005. Una aplicación puede crear un objeto SqlDependency y registrarlo para recibir notificaciones a través del controlador de eventos OnChangeEventHandler.

System..::.Object
  System.Data.SqlClient..::.SqlDependency

Espacio de nombres:  System.Data.SqlClient
Ensamblado:  System.Data (en System.Data.dll)
Visual Basic
Public NotInheritable Class SqlDependency
C#
public sealed class SqlDependency
Visual C++
public ref class SqlDependency sealed
F#
[<Sealed>]
type SqlDependency =  class end

El tipo SqlDependency expone los siguientes miembros.

  NombreDescripción
Método públicoSqlDependency()()()Crea una nueva instancia de la clase SqlDependency con la configuración predeterminada.
Método públicoSqlDependency(SqlCommand)Crea una nueva instancia de la clase SqlDependency y la asocia al parámetro SqlCommand.
Método públicoSqlDependency(SqlCommand, String, Int32)Crea una nueva instancia de la clase SqlDependency, la asocia al parámetro SqlCommand y especifica las opciones de notificación y un valor de tiempo de espera.
Arriba
  NombreDescripción
Propiedad públicaHasChangesObtiene un valor que indica si ha cambiado uno de los conjuntos de resultados asociados a la dependencia.
Propiedad públicaIdObtiene un valor que identifica únicamente esta instancia de la clase SqlDependency.
Arriba
  NombreDescripción
Método públicoAddCommandDependencyAsocia un objeto SqlCommand a esta instancia de SqlDependency.
Método públicoEquals(Object)Determina si el objeto Object especificado es igual al objeto Object actual. (Se hereda de Object).
Método protegidoFinalizePermite que un objeto intente liberar recursos y realizar otras operaciones de limpieza antes de ser reclamado por la recolección de elementos no utilizados. (Se hereda de Object).
Método públicoGetHashCodeActúa como función hash para un tipo concreto. (Se hereda de Object).
Método públicoGetTypeObtiene el objeto Type de la instancia actual. (Se hereda de Object).
Método protegidoMemberwiseCloneCrea una copia superficial del objeto Object actual. (Se hereda de Object).
Método públicoMiembro estáticoStart(String)Inicia el agente de escucha para recibir notificaciones de cambio de dependencia desde la instancia de SQL Server que especifique la cadena de conexión.
Método públicoMiembro estáticoStart(String, String)Inicia el agente de escucha para recibir notificaciones de cambio de dependencia desde la instancia de SQL Server que especifique la cadena de conexión utilizando la cola de SQL Server Service Broker indicada.
Método públicoMiembro estáticoStop(String)Detiene un agente de escucha de una conexión especificada en una anterior llamada a Start.
Método públicoMiembro estáticoStop(String, String)Detiene un agente de escucha de una conexión especificada en una anterior llamada a Start.
Método públicoToStringDevuelve una cadena que representa el objeto actual. (Se hereda de Object).
Arriba
  NombreDescripción
Evento públicoOnChangeSe produce al recibir una notificación para cualquiera de los comandos asociados a este objeto SqlDependency.
Arriba

SqlDependency es ideal para almacenar escenarios en memoria caché cuando la aplicación ASP.NET o el servicio de nivel medio necesitan mantener determinada información almacenada en memoria caché. SqlDependency le permite recibir las notificaciones cuando los datos originales de la base de datos cambian para que la memoria caché pueda estar actualizada.

Para establecer una dependencia, es necesario asociar un objeto SqlDependency a uno o varios objetos SqlCommand. Para recibir notificaciones, es necesario suscribirse al evento OnChange. Para obtener más información sobre los requisitos para crear consultas para las notificaciones, vea "Creating a Query for Notification" en los Libros en pantalla de SQL Server.

NotaNota

La clase SqlDependency se ha diseñado para utilizarla en ASP.NET o en los servicios de nivel medio donde hay un número relativamente pequeño de servidores con dependencias activas a la base de datos. No está diseñada para usarla en aplicaciones cliente, en las que cientos o miles de equipos cliente tendrían establecidos objetos SqlDependency para un único servidor de bases de datos.

SqlDependency requiere la versión 2.0 de .NET Framework y SQL Server 2005. Para obtener más información, vea Notificaciones de consulta en SQL Server (ADO.NET) y "Building Notification Solutions" en los Libros en pantalla de SQL Server.

NotaNota

El evento OnChange se puede generar en un subproceso diferente del que inició la ejecución de comandos.

Las notificaciones de consulta solo son compatibles con las instrucciones SELECT que cumplen ciertos requisitos específicos. En la tabla siguiente se proporcionan vínculos a la documentación sobre Service Broker y las notificaciones de consulta de los Libros en pantalla de SQL Server.

.NET Framework

Compatible con: 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Compatible con: 4, 3.5 SP1

Windows 7, Windows Vista SP1 o posterior, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (no se admite Server Core), Windows Server 2008 R2 (se admite Server Core con SP1 o posterior), Windows Server 2003 SP2

.NET Framework no admite todas las versiones de todas las plataformas. Para obtener una lista de las versiones compatibles, vea Requisitos de sistema de .NET Framework.
Todos los miembros static (Shared en Visual Basic) públicos de este tipo son seguros para la ejecución de subprocesos. No se garantiza que los miembros de instancias sean seguros para la ejecución de subprocesos.
Contenido de la comunidad   ¿Qué es Community Content?
Agregar contenido nuevo RSS  Anotaciones
Processing
© 2012 Microsoft. Reservados todos los derechos. Términos de uso | Marcas Registradas | Privacidad
Page view tracker