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?
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?
Use the sql.
ReplyDeleteMaybe:
if not colidx = fldcount-1 then mds.next
Steve Riley Of course, you're right, you can’t. Bill was right, it was getting late, and my brain was fuzzy as well. :-)
ReplyDeleteNEW: 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.
ReplyDeleteBut 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.