You are not logged in.
Pages: 1
Hello,
I am able to create a DataSet and fill it like this:
function TMormotConnection.GetDataset(pvSQL: RawUTF8): TClientDataset;
But I need to do it in this way:
function TMormotConnection.OpenDataset(pvDataset: TClientDataset; pvSQL: RawUTF8): Boolean;
But it keeps giving me errors.
The statement that calls the function is this one:
lvDataSet := TClientDataset.Create(nil);
lvDataSet := TMormotConnection.Connection.GetDataset(Format('SELECT * FROM AllKeyLists WHERE Name = ''%s''',
[UpperCase(pvListName)]));
Here are the full functions.
function TMormotConnection.GetDataset(pvSQL: RawUTF8): TClientDataset;
var
fJSON: RawUTF8;
fSQLDataset: TSynSQLTableDataSet;
begin
if fService <> nil then
begin
fJSON := fService.Execute(pvSQL, true, true);
fSQLDataset := JSONToDataSet(nil, fJSON);
Result := JSONToClientDataSet(fSQLDataset, fJSON, fClient);
end
else
ShowMessage('There is no connection with the mORMot Server.');
end;
function TMormotConnection.OpenDataset(pvDataset: TClientDataset; pvSQL: RawUTF8): Boolean;
var
fJSON: RawUTF8;
begin
if fService <> nil then
begin
fJSON := fService.Execute(pvSQL, true, true);
pvDataset.active := true;
JSONToClientDataSet(pvDataset, fJSON, fClient);
end
else
ShowMessage('There is no connection with the mORMot Server.');
Result := True;
end;
The GetDataSet function works and returns the Dataset, but the OpenDataset function keeps giving me errors.
When I remove pvDataset.Active := true, I get the error: "Cannot perform this operation on a closed dataset."
When I add pvDataset.Active or pvDataset.Open I get the error: "Missing data provider or data packet.".
Please help.
Lorenzo / SHEePYTaGGeRNeP
Offline
Nvm we got it working
Removed pvDataset.Active and changed te JSONToClientDataSet statement from:
JSONToClientDataSet(pvDataset, fJSON, fClient);
to
JSONToClientDataSet(pvDataset, fJSON, fClient, mORMotMidasVCL.TClientDataSetMode.cdsNew );
function TMormotConnection.OpenDataset(pvDataset: TClientDataset;
pvSQL: RawUTF8): Boolean;
var
fJSON: RawUTF8;
begin
if fService <> nil then
begin
fJSON := fService.Execute(pvSQL, true, true);
JSONToClientDataSet(pvDataset, fJSON, fClient, mORMotMidasVCL.TClientDataSetMode.cdsNew );
Reply if you had this problem and this fixed it
Last edited by SHEePYTaGGeRNeP (2014-02-20 10:56:24)
Offline
Pages: 1