SqlCeConnection.FlushFailure 事件

当背景刷新失败时发生。

命名空间:  System.Data.SqlServerCe
程序集:  System.Data.SqlServerCe(在 System.Data.SqlServerCe.dll 中)

语法

声明
Public Event FlushFailure As SqlCeFlushFailureEventHandler
用法
Dim instance As SqlCeConnection
Dim handler As SqlCeFlushFailureEventHandler

AddHandler instance.FlushFailure, handler
public event SqlCeFlushFailureEventHandler FlushFailure
public:
 event SqlCeFlushFailureEventHandler^ FlushFailure {
    void add (SqlCeFlushFailureEventHandler^ value);
    void remove (SqlCeFlushFailureEventHandler^ value);
}
member FlushFailure : IEvent<SqlCeFlushFailureEventHandler,
    SqlCeFlushFailureEventArgs>
JScript 支持使用事件,但不支持声明新事件。

示例

下面的示例演示了如何使用 FlushFailure 事件。

    Public Sub Snippet4()
        Dim conn As SqlCeConnection = Nothing

        Try
            conn = New SqlCeConnection("Data Source = MyDatabase.sdf; Password ='<pwd>'")

            AddHandler conn.FlushFailure, AddressOf conn_FlushFailure

            conn.Open()

            'Flush failure occurs here
            'OnFlushFailure will be called from the background thread.


        Finally
            conn.Close()
        End Try

    End Sub

    Private Sub conn_FlushFailure(ByVal sender As System.Object, ByVal e As SqlCeFlushFailureEventArgs)
        
        Dim errors As SqlCeErrorCollection = e.Errors
        Console.WriteLine("Flush Failure: " + errors(0).Message)

    End Sub
// using System;
// using System.Xml;
// using System.Data;
// using System.Data.SqlServerCe;
// using System.Data.Common;
// using System.Windows.Forms;
/// <summary>
/// Demonstrates the usage of the FlushFailure event
/// </summary>
public class MyForm : Form
{
    public void Snippet4()
    {
                
        SqlCeConnection conn = new SqlCeConnection();
        
        conn.FlushFailure+=new SqlCeFlushFailureEventHandler(conn_FlushFailure);

        conn.Open();
        
        //Flush failure occurs here
        //OnFlushFailure will be called from the background thread.

        conn.Close();       
    }
    void conn_FlushFailure(object sender, SqlCeFlushFailureEventArgs e)
    {
        SqlCeErrorCollection errors = e.Errors;
        Console.WriteLine("Flush Failure:" + errors[0].Message);
    }
}

请参阅

参考

SqlCeConnection 类

System.Data.SqlServerCe 命名空间