IDtBulkPacket.FailedRows

Syntax

FailedRows: Integer;

Description

The FailedRows property returns records amount, during export of which an error occurred.

Example

Executing the example requires the Data.xls file in the disk C root directory.

Sub Main;

Var

ExcelConsumer: IDtExcelConsumer;

Fields: IDtFieldDefinitions;

Field: IDtFieldDefinition;

v, v1: Array;

Pack: IDtBulkPacket;

Begin

//Array passed in the first packet

//Array passed in the second packet

ExcelConsumer := New DtExcelConsumer.Create;

ExcelConsumer.File := "c:\Data.xls";

ExcelConsumer.HasHeader := True;

ExcelConsumer.DriverVersion := "Excel 8.0";

ExcelConsumer.Table := "Sheet1";

Fields := ExcelConsumer.Fields;

Field := Fields.Add;

Field.DataType := DbDataType.String;

Field.Name := "Name";

Field := Fields.Add;

Field.DataType := DbDataType.Integer;

Field.Name := "Identifier";

Field := Fields.Add;

Field.DataType := DbDataType.Float;

Field.Name := "Value";

ExcelConsumer.Open;

Pack := New DtBulkPacket.Create;

Pack.FailPolicy := DatasetFailPolicy.Rollback;

//First packet

Pack.Data := v;

ExcelConsumer.PutBulk(Pack);

If Not Pack.Successful Then

Debug.WriteLine("Error during packet export");

Debug.WriteLine("Entries are not exported: " + Pack.FailedRows.ToString);

Else

Debug.WriteLine("Packet export is successfully completed");

End If;

//Second packet

Pack.Data := v1;

ExcelConsumer.PutBulk(Pack);

If Not Pack.Successful Then

Debug.WriteLine("Error on packet export");

Debug.WriteLine("Entries are not exported: " + Pack.FailedRows.ToString);

Else

Debug.WriteLine("Packet export is successfully completed");

End If;

ExcelConsumer.Close;

End Sub Main;

After executing the example a new data consumer, that exports data in Excel file, is created. Values of two arrays are in turns written in file. Information about export results is displayed in the development environment console.

See also:

IDtBulkPacket