OleDbErrorCollection.CopyTo OleDbErrorCollection.CopyTo OleDbErrorCollection.CopyTo OleDbErrorCollection.CopyTo Method

Definition

Copies the elements of the OleDbErrorCollection into an Array.

Overloads

CopyTo(Array, Int32) CopyTo(Array, Int32) CopyTo(Array, Int32)

Copies the elements of the OleDbErrorCollection into an Array, starting at the specified index within the Array.

CopyTo(OleDbError[], Int32) CopyTo(OleDbError[], Int32) CopyTo(OleDbError[], Int32) CopyTo(OleDbError[], Int32)

Copies all the elements of the current OleDbErrorCollection to the specified OleDbErrorCollection starting at the specified destination index.

CopyTo(Array, Int32) CopyTo(Array, Int32) CopyTo(Array, Int32)

Copies the elements of the OleDbErrorCollection into an Array, starting at the specified index within the Array.

public:
 virtual void CopyTo(Array ^ array, int index);
public void CopyTo (Array array, int index);
abstract member CopyTo : Array * int -> unit
override this.CopyTo : Array * int -> unit

Parameters

array
Array Array Array Array

The Array into which to copy the elements.

index
Int32 Int32 Int32 Int32

The starting index of the array.

Implements

Exceptions

The sum of index and the number of elements in the OleDbErrorCollection is greater than the length of the Array.

Examples

The following example displays each OleDbError within the OleDbErrorCollection collection.

public void DisplayOleDbErrorCollection(OleDbException exception) 
{
   for (int i=0; i < exception.Errors.Count; i++)
   {
      MessageBox.Show("Index #" + i + "\n" +
             "Message: " + exception.Errors[i].Message + "\n" +
             "Native: " + exception.Errors[i].NativeError.ToString() + "\n" +
             "Source: " + exception.Errors[i].Source + "\n" +
             "SQL: " + exception.Errors[i].SQLState + "\n");
   }
}
Public Sub DisplayOleDbErrorCollection(exception As OleDbException)
    Dim i As Integer

    For i = 0 To exception.Errors.Count - 1
        MessageBox.Show("Index #" + i.ToString() + ControlChars.Cr _
           + "Message: " + exception.Errors(i).Message + ControlChars.Cr _
           + "Native: " + exception.Errors(i).NativeError.ToString() + ControlChars.Cr _
           + "Source: " + exception.Errors(i).Source + ControlChars.Cr _
           + "SQL: " + exception.Errors(i).SQLState + ControlChars.Cr)
    Next i
End Sub
See also

CopyTo(OleDbError[], Int32) CopyTo(OleDbError[], Int32) CopyTo(OleDbError[], Int32) CopyTo(OleDbError[], Int32)

Copies all the elements of the current OleDbErrorCollection to the specified OleDbErrorCollection starting at the specified destination index.

public:
 void CopyTo(cli::array <System::Data::OleDb::OleDbError ^> ^ array, int index);
public void CopyTo (System.Data.OleDb.OleDbError[] array, int index);
member this.CopyTo : System.Data.OleDb.OleDbError[] * int -> unit
Public Sub CopyTo (array As OleDbError(), index As Integer)

Parameters

array
OleDbError[]

The OleDbErrorCollection that is the destination of the elements copied from the current OleDbErrorCollection.

index
Int32 Int32 Int32 Int32

A 32-bit integer that represents the index in the OleDbErrorCollection at which copying starts.

Examples

The following example displays each OleDbError within the OleDbErrorCollection collection.

public void DisplayOleDbErrorCollection(OleDbException exception) 
{
   for (int i=0; i < exception.Errors.Count; i++)
   {
      MessageBox.Show("Index #" + i + "\n" +
             "Message: " + exception.Errors[i].Message + "\n" +
             "Native: " + exception.Errors[i].NativeError.ToString() + "\n" +
             "Source: " + exception.Errors[i].Source + "\n" +
             "SQL: " + exception.Errors[i].SQLState + "\n");
   }
}
Public Sub DisplayOleDbErrorCollection(exception As OleDbException)
    Dim i As Integer

    For i = 0 To exception.Errors.Count - 1
        MessageBox.Show("Index #" + i.ToString() + ControlChars.Cr _
           + "Message: " + exception.Errors(i).Message + ControlChars.Cr _
           + "Native: " + exception.Errors(i).NativeError.ToString() + ControlChars.Cr _
           + "Source: " + exception.Errors(i).Source + ControlChars.Cr _
           + "SQL: " + exception.Errors(i).SQLState + ControlChars.Cr)
    Next i
End Sub
See also

Applies to