View Issue Details

IDProjectCategoryView StatusLast Update
0001825JEDI VCL00 JVCL Componentspublic2004-08-03 07:37
ReporterpuydAssigned Toobones 
Status resolvedResolutionfixed 
Product Version 
Target VersionFixed in Version 
Summary0001825: TJvgExportDataset can't excute when the DataSet use dynamically allocated field components.
DescriptionIf DataSet use dynamically allocated field components( the property DataSet.DefaultFields=True ), TJvgExportDataset.Excute will be failed.
The errormessage is 'Fieldname missing'.
Because at the JvgExportComponents line 595,the function name is 'procedure TJvgExportDataset.Execute',code is 'Dest.FieldDefs.Add(DataSet.Fields[I].Name, FieldType,
      DataSet.Fields[I].Size, DataSet.Fields[I].Required)',
if DataSet use dynamically allocated field components,the 'DataSet.Fields[I].Name' is Empty.May be it will be changed by 'DataSet.Fields[I].FieldName'.
Additional InformationSorry,I'm from China and my English is too pool.
TagsNo tags attached.



2004-06-01 22:22

reporter   ~0004429

By the way.If use this mothed to export dataset.It can't work when the fieldname of source dataset is not same with the destination dataset.Are there any mothed to resolve this matter?


2004-06-03 01:14


Have you tried changing Fields[i].Name to Fields[i].FieldName? Does it work?

To copy from one dataset to another with different fieldnames, you can either use their filed indices (if they match up) or some kind of mapping method where you specify the name of the source field and the name of the matching dest field, i.e:


You would then have to write a method that retrieves the dest name from the source name and copies the field.

I don't think there are any ready made components for that except possibly TBatchMove (standard Delphi BDE). There aren't in JVCL anyway (AFAIK)


2004-06-03 19:55

reporter   ~0004455

Last edited: 2004-06-03 19:59

This is my code:

procedure TJvgExportDataset.Execute;
  I, RecNo, RecCount: Integer;
  Dest: TDataset;
  AllowExportRecord: Boolean;
  FieldType: TFieldType;
  inherited Execute;

  Dest := nil;
  if Assigned(FOnCreateDest) then
    FOnCreateDest(Self, Dest);
  if Dest = nil then
  for I := 0 to DataSet.FieldCount - 1 do
    FieldType := DataSet.Fields[I].DataType;
    if FieldType = ftAutoInc then
      FieldType := ftInteger;
    // delete this line will support dynamically generated field components.
     Dest.FieldDefs.Add(DataSet.Fields[I].FieldName, FieldType,
      DataSet.Fields[I].Size, DataSet.Fields[I].Required);

    RecCount := DataSet.RecordCount;
    RecNo := 0;
    while not DataSet.EOF do
      AllowExportRecord := True;
      if Assigned(FOnExportRecord) then
        FOnExportRecord(Self, DataSet, AllowExportRecord);
      if AllowExportRecord then
        for I := 0 to DataSet.FieldCount - 1 do
          if DataSet.Fields[I].DataType in [ftString, ftMemo] then
            Dest.Fields[I].Value := GetFieldValue(DataSet.Fields[I])
            Dest.Fields[I].Value := DataSet.Fields[I].Value;
      DoProgress(0, RecCount, RecNo, '');
    DoProgress(0, RecCount, RecCount, '');
    if Assigned(FOnSaveDest) then
      FOnSaveDest(Self, Dest);

edited on: 06-03-04 19:59


2004-06-03 20:56

reporter   ~0004456

An other question:

At the last of these code, after the Dest DataSet Close, why must to FreeAndNil(dest)? I think,free the Dest is not a good idea. Because when Export is done,I will use the Dest DataSet at next time.


2004-06-10 01:58


> why must to FreeAndNil(dest)?
A minor change can prevent this:

  if Assigned(FOnSaveDest) then
    FOnSaveDest(Self, Dest);
if Dest <> nil then

Now, if you set Dest := nil in your OnSaveDest handler, the dataset is not freed and you can reuse it as may times as you like.


2004-06-10 02:04


Last edited: 2004-06-10 02:04

Why not just check if the fields are the defaults or not, i.e:
  for I := 0 to DataSet.FieldCount - 1 do
    FieldType := DataSet.Fields[I].DataType;
    if FieldType = ftAutoInc then
      FieldType := ftInteger;
if not DataSet.DefaultFields then
      Dest.FieldDefs.Add(DataSet.Fields[I].Name, FieldType,
        DataSet.Fields[I].Size, DataSet.Fields[I].Required);

edited on: 06-10-04 02:04


2004-06-15 06:19


The fix has been added to CVS, so please try it out.


2004-08-03 07:37

administrator   ~0004898

This bug has not had any activity for more than a month, it is therefore considered fixed.
To the original poster: If you think the issue is still there, even after having tested with the JVCL3, please create a new bug report.

To get the latest JCL and JVCL please go to these sites:

Issue History

Date Modified Username Field Change
2004-06-01 22:11 puyd New Issue
2004-06-01 22:22 puyd Note Added: 0004429
2004-06-03 01:14 user72 Note Added: 0004446
2004-06-03 06:40 user72 Status new => feedback
2004-06-03 19:55 puyd Note Added: 0004455
2004-06-03 19:59 puyd Note Edited: 0004455
2004-06-03 20:56 puyd Note Added: 0004456
2004-06-10 01:58 user72 Note Added: 0004527
2004-06-10 02:04 user72 Note Added: 0004528
2004-06-10 02:04 user72 Note Edited: 0004528
2004-06-15 06:19 user72 Note Added: 0004560
2004-08-03 07:37 obones Status feedback => resolved
2004-08-03 07:37 obones Resolution open => fixed
2004-08-03 07:37 obones Assigned To => obones
2004-08-03 07:37 obones Note Added: 0004898