Jump to content

how to inser sql data in uniServerModule events OnHTTPCommand


billyChou

Recommended Posts

modify Demos\Desktop\FishFacts samples

 

 

//-----------------------

unit ServerModule;
                                                          

interface                                                 

                                                          

uses                                                      
Variants, Classes, SysUtils, uniGUIServer, uniGUIMainModule, uniGUIApplication, uIdCustomHTTPServer;
                                                    

type                                                      

  TUniServerModule = class(TUniGUIServerModule)

    procedure UniGUIServerModuleCreate(Sender: TObject);

    procedure UniGUIServerModuleHTTPCommand(ARequestInfo: TIdHTTPRequestInfo;
      AResponseInfo: TIdHTTPResponseInfo; var Handled: Boolean);

  private

    { Private declarations }

   protected

    procedure FirstInit; override;
  public

    { Public declarations }

    CurrentTheme : string;

  end;


function UniServerModule: TUniServerModule;


implementation


{$R *.dfm}


uses

  UniGUIVars, MainModule;
 

 

procedure TUniServerModule.UniGUIServerModuleHTTPCommand(

  ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo;
  var Handled: Boolean);
begin


    if ARequestInfo.URI = '/test2' then  begin

       // ARequestInfo.QueryParams;
       //** I can't get params.values['search_me']
       rs := '' ;
      try
         
        // UniMainModule.ClientDataSet.Active := true;
          UniMainModule.ClientDataSet.Insert; // error
          UniMainModule.ClientDataSet.FieldByName('Category').Value := 'test';
          UniMainModule.ClientDataSet.Post;
       except
         
       end;

       Handled := true;
    end;



end;

//-----------------------------------

Thanks

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...