Redigera

Dela via


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:
 virtual void CopyTo(Array ^ array, int i);
public void CopyTo (Array array, int i);
abstract member CopyTo : Array * int -> unit
override this.CopyTo : Array * int -> unit
Public Sub CopyTo (array As Array, i As Integer)

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");
   }
}
Public Sub DisplayOdbcErrorCollection(exception As OdbcException)
    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

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(cli::array <System::Data::Odbc::OdbcError ^> ^ array, int i);
public void CopyTo (System.Data.Odbc.OdbcError[] array, int i);
member this.CopyTo : System.Data.Odbc.OdbcError[] * int -> unit
Public Sub CopyTo (array As OdbcError(), i As Integer)

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");
   }
}
Public Sub DisplayOdbcErrorCollection(exception As OdbcException)
    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