OdbcErrorCollection.CopyTo Method

Definition

Copies the elements of the OdbcErrorCollection into an array, starting at the specified index within the array.

Overloads

CopyTo(Array, Int32)

Copies the elements of the OdbcErrorCollection into an array, starting at the specified index within the array.

CopyTo(OdbcError[], Int32)

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

CopyTo(Array, Int32)

Source:
OdbcErrorCollection.cs
Source:
OdbcErrorCollection.cs

Copies the elements of the OdbcErrorCollection into an array, starting at the specified index within the array.

public void CopyTo (Array array, int i);

Parameters

array
Array

The array into which to copy the elements.

i
Int32

The starting index of array.

Implements

Exceptions

The sum of index and the number of elements in the OdbcErrorCollection 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 OdbcError within the OdbcErrorCollection collection.

public void DisplayOdbcErrorCollection(OdbcException 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 9 (package-provided) and other versions
Product Versions
.NET 6 (package-provided), 7 (package-provided), 8 (package-provided), 9 (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 (package-provided), 4.7, 4.7.1 (package-provided), 4.7.1, 4.7.2 (package-provided), 4.7.2, 4.8 (package-provided), 4.8, 4.8.1
.NET Standard 2.0 (package-provided)

CopyTo(OdbcError[], Int32)

Source:
OdbcErrorCollection.cs
Source:
OdbcErrorCollection.cs

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

public void CopyTo (System.Data.Odbc.OdbcError[] array, int i);

Parameters

array
OdbcError[]

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

i
Int32

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

Examples

The following example displays each OdbcError within the OdbcErrorCollection collection.

public void DisplayOdbcErrorCollection(OdbcException 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 9 (package-provided) and other versions
Product Versions
.NET 6 (package-provided), 7 (package-provided), 8 (package-provided), 9 (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 (package-provided), 4.7, 4.7.1 (package-provided), 4.7.1, 4.7.2 (package-provided), 4.7.2, 4.8 (package-provided), 4.8, 4.8.1
.NET Standard 2.0 (package-provided)