IDtConsumer.PutProvider

Syntax

PutProvider(Provider: IDtProvider);

Parameters

Provider - provider, which data has to be exported.

Description

The PutProvider method exports all the values of the specified data provider into the data consumer. For the successful export fields list in the data consumer has to correspond to fields list in the data source.

Example

Executing the example requires the file Data_Out.txt in the disk C root directory and a table in repository with the Table_1.

Sub Main;

Var

MB: IMetabase;

MBProvider: IDtMetabaseProvider;

TextConsumer: IDtTextConsumer;

Fields1, Fields2: IDtFieldDefinitions;

Field: IDtFieldDefinition;

i: Integer;

Begin

MB := MetabaseClass.Active;

MBProvider := New DtMetabaseProvider.Create;

MBProvider.Dataset := MB.ItemById("Table_1").Bind As IDatasetModel;

Fields1 := MBProvider.Fields;

TextConsumer := New DtTextConsumer.Create;

TextConsumer.File := "c:\Data_Out.txt";

TextConsumer.WriteHeader := True;

TextConsumer.RowDelimiter := #13 + #10; //Carriage return + row transfer

TextConsumer.DelimitedColumnDelimiter := #9; //Button Tab

Fields2 := TextConsumer.Fields;

For i := 0 To Fields1.Count - 1 Do

Field := Fields2.Add;

Field.DataType := Fields1.Item(i).DataType;

Field.Name := Fields1.Item(i).Name;

End For;

TextConsumer.Open;

TextConsumer.Clear;

TextConsumer.PutProvider(MBProvider);

TextConsumer.Close

End Sub Main;

After executing the example a new data consumer that exports data in text file is created. During export the Carriage return+Row transfer combination is used as a row delimiter, and Tabulation symbol - as a field delimiter. Into the first file row field names are written. Then all the data from the table Table_1 are exported to the file.

See also:

IDtConsumer