SEGNA Posted February 22, 2023 Share Posted February 22, 2023 Hi, I want to connect the string FormName parameter that comes with the UniGUIServerModuleHTTPCommand procedure to a previously created form with that name and access the sql text of the FDqery in it. procedure TUniServerModule.UniGUIServerModuleHTTPCommand( ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo; var Handled: Boolean); var prmFormName, s : string; Form : TUniForm; begin if ARequestInfo.Command = 'GET' then if ARequestInfo.URI = '/test' then begin prm := ARequestInfo.Params.Values['FormName']; s := Form.FDQuery1.SQL.Text; // The example here is simplified. I tried to reach with Formclass but I get "Address Access Violation" warning. // // The form I want to connect to was previously created in uniapliacation. This form can be a MainForm or an open form with a list of Customers. // // I need the sql text of the FDquery in that form. end; end; Quote Link to comment Share on other sites More sharing options...
SEGNA Posted February 22, 2023 Author Share Posted February 22, 2023 One of the code i used : FDQery.Sql.Text := (TUniForm(UniApplication.FindComponent('MainForm') as TUniForm ).FindComponent( 'FDQuery1' ) as TFDQuery).SQL.Text; Quote Link to comment Share on other sites More sharing options...
Sherzod Posted February 22, 2023 Share Posted February 22, 2023 2 hours ago, SEGNA said: a previously created form with that name Hello, Please explain in more details. Quote Link to comment Share on other sites More sharing options...
SEGNA Posted February 22, 2023 Author Share Posted February 22, 2023 Hi, As an example I am sending parameters by running GET method inside MainForm with htmlframe "http://localhost:8077/test?FormName=MainForm&Data=FDQuery1" On the serverModule side, when I receive the incoming call in UniGUIServerModuleHTTPCommand, I need to connect to the form in the parameter and get the sql text of the dataset. I cannot access MainForm or any other active form from within ServerModule. I need to make calculations on the sql side and send the result as text. procedure TUniServerModule.UniGUIServerModuleHTTPCommand( ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo; var Handled: Boolean); var prmFormName, prmData, s : string; Form : TUniForm; FDQuery: TFDQuery; begin if ARequestInfo.Command = 'GET' then if ARequestInfo.URI = '/test' then begin prm := ARequestInfo.Params.Values['FormName']; prmDataSet := ARequestInfo.Params.Values['Data']; /// ConnectionCreate ..... FDQuery := FDQuery.Create; FDQuery.Connection := ....; FDQuery.Sql.Text := TUniForm(UniApplication.FindComponent('MainForm') as TUniForm ).FindComponent( 'FDQuery1' ) as TFDQuery).SQL.Text; FDQuery.Open; //I need to make calculations on the sql side and send the result. as text. AResponseInfo.ContentText := Result; AResponseInfo.WriteContent; end; end; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.