Export (0) Print
Expand All

SqlCeErrorCollection.CopyTo Method

Copies the elements of the SqlCeErrorCollection into an Array, starting at the given index within the Array.

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

public void CopyTo(
	Array array,
	int index
)

Parameters

array
Type: System.Array
The Array into which to copy the elements.
index
Type: System.Int32
The starting index of the array.

Implements

ICollection.CopyTo(Array, Int32)

ExceptionCondition
ArgumentException

The sum of index and the number of elements in the SqlCeErrorCollection is greater than the Length of the Array.

ArgumentNullException

The array is null.

ArgumentOutOfRangeException

The index is not valid for the array.

The following example displays each SqlCeError within the SqlCeErrorCollection collection.

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