KeyFieldNames: String;
The KeyFieldNames property determines the list of key fields by values of which updated entries are searched. Fields in the list are separated with the ; symbol.
Executing the example requires that a repository contains a table with the Table_1 identifier and the Excel file named Data.xls in the disk C root directory. Data type and a number of columns with data in Excel file correspond to table fields list.
Sub Main;
Var
MB: IMetabase;
ExcelProvider: IDtExcelProvider;
MBConsumer: IDtMetabaseConsumer;
Fields: IDtFieldDefinitions;
Begin
MB := MetabaseClass.Active;
//New provider
ExcelProvider := New DtExcelProvider.Create;
ExcelProvider.DriverVersion := "Excel 8.0";
ExcelProvider.File := "c:\Data.xls";
ExcelProvider.HasHeader := True;
ExcelProvider.Query := "Select * From [Sheet1$]";
//New consumer
MBConsumer := New DtMetabaseConsumer.Create;
MBConsumer.Dataset := MB.ItemById("Table_1").Bind As IDatasetModel;
Fields := MBConsumer.Fields;
MBConsumer.Open;
MBConsumer.KeyFieldNames := Fields.Item(0).Name;
MBConsumer.PutProvider(ExcelProvider);
MBConsumer.Close
End Sub Main;
After executing the example a new data provider and data consumer are created. Source is set on import from Excel file. Consumer is set on data export to the repository table. During data export entries are updated by the content of the first table field.
See also: