Must be getting late, and my brain is fuzzy. Given this code:

Must be getting late, and my brain is fuzzy. Given this code:
  for colIdx := 0 to MyDataSet.Fields.Count - 1 do
    with cdsMain.FieldDefs.AddFieldDef do
    begin
      DataType := MyDataSet.Fields[colIdx].DataType;
      Name := MyDataSet.Fields[colIdx].Name;
      Size := MyDataSet.Fields[colIdx].Size;
    end;

How can I be getting a list out of bounds error on MyDataSet?

Comments

  1. Use the sql.
    Maybe:
    if not colidx = fldcount-1 then mds.next

    ReplyDelete
  2. Steve Riley Of course, you're right, you can’t. Bill was right, it was getting late, and my brain was fuzzy as well. :-)

    ReplyDelete
  3. NEW: On close inspection, it turns out that doing the assign on FieldDefs had some issues. For now, I am using the incoming dataset as it is, and will revisit the issue when I have more time.

    But the short story is this: after assigning the field defs from the original to the TClientDataSet, one column was missing. Nothinf special there, it's a string column, and not a caclulated col. Just a mystery.

    ReplyDelete

Post a Comment