You are not logged in.
Pages: 1
Hi all
I Use this code:
var vValues: TDocVariantData;
vValues.InitJSON(MyModelHttpClient.RetrieveListJSON(TSQLMyRecord,'',''),JSON_OPTIONS[true]);
but in some cases, result of RetriveListJSON call is 0 records.
In this cases, some information is added in vValues. I use vValues to fill a DbGrid.DataSource.DataSet :
MyGrid.DataSource.DataSet := ToDataSet(self,vValues.Values,[],[]);
when 0 records is the result of RetrieveListJSON call, i have a exception _Self(0<>1) ...
Is there any way to find out if the number of records returned by RetrieveListJSON = 0 ?
Thanks
Rodrigo
Offline
Hi Rodrigo, see the TDocVariantData "count" method.
Offline
Hi Mauricio,
Yes, I had seen this property, however it did not work properly in this case
Without any data in the table, the RetrieveList and vValues.InitJson method returns the following:
(275, [dvoIsObject, dvoReturnNullForUnknownProperty, dvoValueCopiedByReference], ('fieldCount', 'values',' rowCount '), (5,' ["ID", "Acronym", "Description", "Type", "Id_Merc") ', 0), 3)
And the count property returns the number 3, but there is no record in the table
Offline
use rowCount property, expanded JSON always return this when the query return empty dataset.
Esteban
Offline
Try this.
MyGrid.DataSource.DataSet := JSONToDataSet(self, MyModelHttpClient.RetrieveListJSON(TSQLMyRecord,'',''));
Offline
EMartin
How do I get access to this property?
Mauricio
Yes, using JSONToDataset works, but this method uses the unit MormotVCL and I migrated the example to an FMX client, and the JSONtoDataset method does not work with FMX so I am trying to use the ToDataset method and directly manipulate the return in DocVariantData. If there is any other alternative for FMX clients I'm happy to find out
Offline
EMartin
How do I get access to this property?
you are see a DocVariantData and can access to property in this way:
DocVariantData(variantdoc).value['rowCount']
Esteban
Offline
Pages: 1