Einzelnen Beitrag anzeigen

Kostas

Registriert seit: 14. Mai 2003
Ort: Gerstrhofen
1.058 Beiträge
 
Delphi 10 Seattle Enterprise
 
#12

AW: DataSnap ein TFDJSONDataSets als TJSONObject übertragen

  Alt 25. Mär 2015, 16:09
Hallo zusammen,

so funktioniert es jetzt einwandfrei. Dankeschön Uwe.

Delphi-Quellcode:
-------------------------------SERVER---------------------
function TdmDALZMI.GetBauJSONStr(BauNr:integer): String;
var
   stream: TStringStream;
begin
   stream := TStringStream.Create;
   try
     qrGetBau.Active := False;
     qrGetBau.Params[0].Value := BauNr;
     qrGetBau.Active := True;

     qrGetBau.SaveToStream(stream, TFDStorageFormat.sfJSON);
     stream.Seek(0, soFromBeginning);
     qrGetBau.Active := False;
     result := stream.DataString;
   finally
     stream.Free;
   end;
end;

-------------------------------CLIENT---------------------

procedure TdmZMI.GetBauJSONStr(BauNr:integer);
var
  LDataSetList: TFDJSONDataSets;
  LJSONStr: String;
  LZMIClient: TdmServerMethodsZMIClient;

begin
  LZMIClient := TdmServerMethodsZMIClient.Create(CMClientModule.CMCSQLConnection.DBXConnection);
  try
    LJSONStr := LZMIClient.ZMI_GetBauJSONStr(BauNr);

    JSONToDataSet(LJSONStr, mtBau);
  finally
    LZMIClient.Free;
  end;


  mtBau.Open;
end;

procedure TdmZMI.JSONToDataSet(const Source: string; Target: TFDDataSet);
var
   stream: TStringStream;
begin
   stream := TStringStream.Create(Source);
   try
     Target.LoadFromStream(stream, TFDStorageFormat.sfJSON);
   finally
     stream.Free;
   end;
end;

Gruß Kostas
  Mit Zitat antworten Zitat