#1 2015-06-16 12:56:05

DigDiver
Member
Registered: 2013-04-29
Posts: 137

DataSetToJSON from SynVirtualDataSet and calculated field

function DataSetToJSON(Data: TDataSet): RawUTF8;

When Data contains a calculated field, the exception "Argument out of range" is raised.
For example, DevExpress TdxMemData component contains the hidden calculated field RecID. And this function cannot return JSON for TdxMemData.

To fix - it's needed to change Data.FieldDefs[f].Name to Data.Fields[f].FieldName:

    // get col names and types
    SetLength(W.ColNames,Data.FieldCount);
    for f := 0 to high(W.ColNames) do
     StringToUTF8(Data.Fields[f].FieldName,W.ColNames[f]);       //  instead of Data.FieldDefs[f].Name

Offline

Board footer

Powered by FluxBB