You are not logged in.
Hi all,
We use Mormot on a new project with extreme success, but we are working on using mormot in an old legacy project that basically uses UNIQuery and IBQuery Datasets.
We want to load the records in these DataSets, but it has not worked well using the JSONTODataset implementation
It works
DbGrid1.DataSource.DataSet: = JSONToDataSet (Self, fService.Execute (aSQL, True, False));
but this does not work
UniQuery1: = TUniQuery (JSONToDataSet (Self, fService.Execute (aSQL, True, False)));
How do we proceed?
Offline
The class instance returend by JSONToDataSet is not a TUniQuery, so hard casting as you do is properly invalid.
The following won't compile:
UniQuery1: = JSONToDataSet (Self, fService.Execute (aSQL, True, False))) as TUniQuery;
I think you have to change the UniQuery1 type to a plain TDataSet....
Offline
Thanks Ab
Now it works
I have one more newbie question
In this case, UniQuery1 has named added TFields, for example:
UniQuery1ID_TABLE INTEGER
UniQuery1NAME STRING
and
fService.Execute ('SELECT ID_TABLE, NAME FROM COMPANIES', True, True) returns correctly
In UniQuery1 I can correctly access the values in TUniQuery using UniQuery1.Fields [0] and UniQuery1.Fields [1]
I can also access using UniQuery1.FieldByName ('ID_TABLE') AsInteger and UniQuery1.FieldByName ('NAME') AsString and UniQuery.RecordCount is correct
But I can not directly access UniQuery1ID_TABLE.AsInteger nor UniQuery1NAME.ASString and this is used in my legacy code
The values come empty when I access the fields directly
How do we proceed?
Last edited by triguinhu (2018-10-31 13:44:03)
Offline
This notation used in our legacy application repeats thousands of times throughout the code.
I would like some help from you to get out of this question if possible, otherwise it will not be approved by our directors to change the legacy code to use mormot in this application
Offline
Hello guys
What would be the best way to keep the reference to the Query object without creating a new reference by assigning JSOntoDataset to a Query?
When I do MyUniQuery := JSONTODataset (something) I create a new reference and I can not access the named TFields among other things ..
How do I get the result of JSONtoDataset in the same reference of my UniQuery?
Last edited by triguinhu (2018-11-20 11:43:29)
Offline
This is because you use persistence field in your legacy application.
You have to adapt all direct call to persisted field UniQuery1ID_TABLE to UniQuery.FieldByName('ID_TABLE').Asxxxxxx.
Andry
Offline