Home > Back-end >  In a dynamic library call Datasnap function, The return type is TFDJSONDatasets error of The Input v
In a dynamic library call Datasnap function, The return type is TFDJSONDatasets error of The Input v

Time:11-12

A server-side function:
The function TServerStockMethods. GetDllDatas (ASql,
AComponentName: String) : TFDJSONDataSets;
Var
AQry: TFDQuery;
//LDataSets: TFDJSONDataSets;
The begin
Try
AQry:=FindComponent (AComponentName) as TFDQuery;
If AQry=nil then exit;
AQry. Close;
AQry. SQL. The Clear;
AQry. SQL. Text:=ASql;
Try
//Create a dataset list
Result:=TFDJSONDataSets. Create;
//Result:=TJSONObject. Create;
//Add the dataset
TFDJSONDataSetsWriter. ListAdd (Result, AQry);
//TFDJSONInterceptor DataSetsToJSONObject (LDataSets, Result);
Except,

end;

Except,

end;

end;

Second, DLL call process:
Procedure TFrmKCFindStock. Action1Execute (Sender: TObject);
Var
AServerStockMethodsClient: TServerStockMethodsClient;
LDataSetList: TFDJSONDataSets;
LDataSet: TFDDataSet;
//LJSONObject: TJSONObject;
The begin
Try
AServerStockMethodsClient:=TServerStockMethodsClient. Create (GSQLConnection. DBXConnection);
LDataSetList:=AServerStockMethodsClient GetDllDatas (PWideChar (' select * from kc_BuyOrder '), PWideChar (' FDQryKCBuyOrder '));

LDataSet:=TFDJSONDataSetsReader GetListValue (LDataSetList, 0);
//Update the UI
FDMemTable1. Active:=False;
FDMemTable1. AppendData (LDataSet);

The finally
AServerStockMethodsClient. Free;

end;
end;

Masters help you see is what reason, thank you,
In the application calls is normal,

CodePudding user response:

BBS ask difficult, put box

CodePudding user response:

The function of the query I have implemented, how to do with FireDAC DataSnap three layer update?
Query methods:
The server-side method
The function TFSMethods. GetData (fSQL: string) : TDataSet;
Var
FDQuery: TFDQuery;
The begin
Result:=nil;
FDQuery:=TFDQuery. Create (nil);
Try
If not FDConn. Connected then FDConn. Connected:=True;

FDQuery. Connection:=FDConn;
If the Trim (fSQL) & lt;> "' then
The begin
FDQuery. Open (fSQL);
Result:=TFDMemTable. Create (nil);
TFDMemTable (Result). Data:=FDQuery. Data;
end;
The finally
FreeAndNil (FDQuery);
FDConn. Connected:=False;
end;
end;

Client calls:
The Class function TRemote. GetData (ASQL: string; FDMTable: TFDMemTable) : Boolean;
The begin
Result:=False;
Try
Try
FCDMod. FDSCon. Connected:=True;
FCDMod. FDSProc. Close;
FCDMod. FDSProc. Unprepare;
FCDMod. FDSProc. StoredProcName:='TFSMethods. GetData';
FCDMod. FDSProc. Prepare;
FCDMod. FDSProc. Params [0]. Value:=ASQL;
FCDMod. FDSProc. Open;

FDMTable. Close;
FDMTable. Data:=FCDMod. FDSProc. Data;

Result:=True;
Except,
On e: the Exception do
The begin
MsgInfo. ShowError (' query failed! '+ e.M essage ErrTitle);
Result:=False;
end;
end;
The finally
FCDMod. FDSProc. Close;
FCDMod. FDSProc. StoredProcName:=';
FCDMod. FDSCon. Connected:=False;
end;
end;

CodePudding user response:

Returned directly TDataSet type, speed is slow, best can return TFDJSONDataSets

CodePudding user response:

In BBS box, doesn't even have a response

CodePudding user response:

AQry. Open;

CodePudding user response:

In addition, the client:
Var FDAdaptedDataset: TFDAdaptedDataset;
FDJsonDatasets: TFDJsonDatasets;
ADOReport: TFDMemoTable;
The begin
FDAdaptedDataset:=TFDJSONDataSetsReader GetListValueByName
(FDJsonDatasets pSelectKey);//the main table: pSelectKey1
If ADOReport. Active=False then ADOReport. AppendData (FDAdaptedDataset);//UI required memory table data
end;

CodePudding user response:

You can refer to the levy of Delphi 10.1 Berlin DataSnap development manual
FD update is often done by TFDSchemaAdapter this control, more convenient, more table cache update
  • Related