OleDbErrorCollection.CopyTo Metod

Definition

Kopierar elementen i OleDbErrorCollection till en Array.

Överlagringar

Name Description
CopyTo(Array, Int32)

Kopierar elementen OleDbErrorCollection i till en Array, med början vid det angivna indexet Arrayi .

CopyTo(OleDbError[], Int32)

Kopierar alla element i den aktuella OleDbErrorCollection till den angivna OleDbErrorCollection med början vid det angivna målindexet.

CopyTo(Array, Int32)

Källa:
OleDbErrorCollection.cs
Källa:
OleDbErrorCollection.cs
Källa:
OleDbErrorCollection.cs
Källa:
OleDbErrorCollection.cs

Kopierar elementen OleDbErrorCollection i till en Array, med början vid det angivna indexet Arrayi .

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
Public Sub CopyTo (array As Array, index As Integer)

Parametrar

array
Array

Till Array vilken elementen ska kopieras.

index
Int32

Startindexet för array.

Implementeringar

Undantag

Summan av index och antalet element i OleDbErrorCollection är större än längden på Array.

array är null.

index Är inte giltigt för array.

Exempel

I följande exempel visas var och en OleDbError i OleDbErrorCollection samlingen.

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

Se även

Gäller för

CopyTo(OleDbError[], Int32)

Källa:
OleDbErrorCollection.cs
Källa:
OleDbErrorCollection.cs
Källa:
OleDbErrorCollection.cs
Källa:
OleDbErrorCollection.cs

Kopierar alla element i den aktuella OleDbErrorCollection till den angivna OleDbErrorCollection med början vid det angivna målindexet.

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)

Parametrar

array
OleDbError[]

Det OleDbErrorCollection är målet för de element som kopieras från den aktuella OleDbErrorCollection.

index
Int32

Ett 32-bitars heltal som representerar indexet OleDbErrorCollection där kopieringen startar.

Exempel

I följande exempel visas var och en OleDbError i OleDbErrorCollection samlingen.

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

Se även

Gäller för