03-12-2014, 07:04 AM
كود :
function TServerMethods.ha_GetStrSQL(Client_strSQL: string): TFDJSONDataSets;
// SQLSTR
var
Count, strSQL, StrSQLUser, Cilent_IP_ADDRESS, USERNO: string;
RecsOut: Integer;
begin
// Clear active so that query will reexecute.
// strSQL := 'SELECT * FROM madcap.ARCT1000 where IP_ADDRESS = ' + '''' + Cilent_IP_ADDRESS + ''''; // hassan good IP_ADDRESS
// StrSQLUser := 'SELECT * FROM madcap.ARCT1000 where OP_USERNO = ' + '''' + USERNO + ''''; // hassan good IP_ADDRESS
FDQuerySQL.Active := False;
FDQuerySQL.SQL.Clear;
FDQuerySQL.SQL.Text := Client_strSQL;
Result := TFDJSONDataSets.Create;
TFDJSONDataSetsWriter.ListAdd(Result, FDQuerySQL); // The "TFDJSONDataSetsWriter" class provides static "ListAdd" method. // It uses reflection to convert results of the query into "TFDJSONDataSets".
end;
---------------------------------
procedure TClientModule.ha_GetStrSQL(StrSQL: string);
var
LDataSetList: TFDJSONDataSets;
begin
try
// Get dataset list containing department names
LDataSetList := ClientModule.ServerMethodsClient.ha_GetStrSQL(StrSQL);
// Update UI
UpdateDepartmentNames(LDataSetList);
except
on E: TDSRestProtocolException do HandleRestException(ClientModule.DSRestConnection , 'ha_GetStrSQL(StrSQL) error', E)
else
raise;
end;
end;
----------
procedure TClientModule.UpdateDepartmentNames(const ADataSetList: TFDJSONDataSets);
begin
// Update UI
FDMemTable.Active := False;
Assert(TFDJSONDataSetsReader.GetListCount(ADataSetList) = 1);
FDMemTable.AppendData( TFDJSONDataSetsReader.GetListValue(ADataSetList, 0));
end;
