Прочетете на английски Редактиране

Споделяне чрез


OleDbErrorCollection.CopyTo Method

Definition

Copies the elements of the OleDbErrorCollection into an Array.

Overloads

CopyTo(Array, Int32)

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

CopyTo(OleDbError[], Int32)

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

CopyTo(Array, Int32)

Source:
OleDbErrorCollection.cs
Source:
OleDbErrorCollection.cs
Source:
OleDbErrorCollection.cs

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

C#
public void CopyTo(Array array, int index);

Parameters

array
Array

The Array into which to copy the elements.

index
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.

The array is null.

The index is not valid for array.

Examples

The following example displays each OleDbError within the OleDbErrorCollection collection.

C#
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");
   }
}

See also

Applies to

.NET 10 (package-provided) и други версии
Продукт Версии
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (package-provided)

CopyTo(OleDbError[], Int32)

Source:
OleDbErrorCollection.cs
Source:
OleDbErrorCollection.cs
Source:
OleDbErrorCollection.cs

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

C#
public void CopyTo(System.Data.OleDb.OleDbError[] array, int index);

Parameters

array
OleDbError[]

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

index
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.

C#
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");
   }
}

See also

Applies to

.NET 10 (package-provided) и други версии
Продукт Версии
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (package-provided)