更新:2007 年 11 月
啟動接聽程式,從連接字串所指定的 SQL Server 執行個體並使用指定的 SQL Server Service Broker 佇列,接收相依性變更告知。
命名空間:
System.Data.SqlClient 組件:
System.Data (在 System.Data.dll 中)
<HostProtectionAttribute(SecurityAction.LinkDemand, ExternalThreading := True)> _
Public Shared Function Start ( _
connectionString As String, _
queue As String _
) As Boolean
Dim connectionString As String
Dim queue As String
Dim returnValue As Boolean
returnValue = SqlDependency.Start(connectionString, _
queue)
[HostProtectionAttribute(SecurityAction.LinkDemand, ExternalThreading = true)]
public static bool Start(
string connectionString,
string queue
)
[HostProtectionAttribute(SecurityAction::LinkDemand, ExternalThreading = true)]
public:
static bool Start(
String^ connectionString,
String^ queue
)
/** @attribute HostProtectionAttribute(SecurityAction.LinkDemand, ExternalThreading = true) */
public static boolean Start(
String connectionString,
String queue
)
public static function Start(
connectionString : String,
queue : String
) : boolean
這個方法會啟動 AppDomain 的接聽程式,從 connectionString 參數所指定的 SQL Server 執行個體接收相依性告知。可以使用不同連接字串,為多個伺服器呼叫這個方法一次以上。
如果未指定佇列名稱,SqlDependency 會在伺服器上建立用於整個程序的暫存佇列和服務,即使該程序涉及一個以上的 AppDomain。此佇列和服務在應用程式關閉時會被自動移除。
在下列限制下,可執行對 Start 方法的多個呼叫:
Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
.NET Framework 和 .NET Compact Framework 並不支援各種平台的所有版本。如需支援平台版本的相關資訊,請參閱 .NET Framework 系統需求。
.NET Framework
支援版本:3.5、3.0、2.0
參考
其他資源