Export (0) Print
Expand All

SqlCeErrorCollection.Count Property

Gets the number of SqlCeError objects in the collection.

Namespace:  System.Data.SqlServerCe
Assembly:  System.Data.SqlServerCe (in System.Data.SqlServerCe.dll)

public int Count { get; }

Property Value

Type: System.Int32
The total number of SqlCeError objects in the collection.

Implements

ICollection.Count

The following example displays each SqlCeError in a SqlCeErrorCollection.

public void DisplaySqlCeErrors(SqlCeErrorCollection errorCollection ) {
    StringBuilder bld = new StringBuilder();

    foreach (SqlCeError err in errorCollection) {
        bld.Append("\n Error Code: " + err.HResult.ToString("X"));
        bld.Append("\n Message   : " + err.Message);
        bld.Append("\n Minor Err.: " + err.NativeError);
        bld.Append("\n Source    : " + err.Source);

        foreach (int numPar in err.NumericErrorParameters) {
            if (0 != numPar) bld.Append("\n Num. Par. : " + numPar);
        }

        foreach (string errPar in err.ErrorParameters) {
            if (String.Empty != errPar) bld.Append("\n Err. Par. : " + errPar);
        }

        MessageBox.Show(bld.ToString());
        bld.Remove(0, bld.Length);
    }
}


Show:
© 2014 Microsoft