共用方式為


StateChange 事件

注意:此 API 已經過時。

發生於連接的狀態變更時。

命名空間:  System.Data.SqlServerCe
組件:  System.Data.SqlServerCe (在 System.Data.SqlServerCe.dll 中)

語法

'宣告
<ObsoleteAttribute("This property is obsolete and will be removed in a future version.")> _
Public Overrides Event StateChange As StateChangeEventHandler
'用途
Dim instance As SqlCeConnection
Dim handler As StateChangeEventHandler

AddHandler instance.StateChange, handler
[ObsoleteAttribute("This property is obsolete and will be removed in a future version.")]
public override event StateChangeEventHandler StateChange
[ObsoleteAttribute(L"This property is obsolete and will be removed in a future version.")]
public:
virtual  event StateChangeEventHandler^ StateChange {
    void add (StateChangeEventHandler^ value);
    void remove (StateChangeEventHandler^ value);
}
[<ObsoleteAttribute("This property is obsolete and will be removed in a future version.")>]
abstract StateChange : IEvent<StateChangeEventHandler,
    StateChangeEventArgs>
[<ObsoleteAttribute("This property is obsolete and will be removed in a future version.")>]
override StateChange : IEvent<StateChangeEventHandler,
    StateChangeEventArgs>
JScript 支援使用事件,但不支援新的宣告。

備註

每當 State 從已關閉變更為已開啟,或從已開啟變更為已關閉時,會引發 StateChange 事件。在 SqlCeConnection 轉換之後,會立即引發 StateChange 事件。

如果事件處理常式從 StateChange 事件內擲回例外狀況,則該例外狀況會轉換至 OpenClose 方法的呼叫端。

除非有明確地呼叫 CloseDispose,否則不會引發 StateChange 事件。

請參閱

參考

SqlCeConnection類別

SqlCeConnection 成員

System.Data.SqlServerCe 命名空間