How to pass a parameter from the server to the client in Datasnap?

0

How can I send and receive data using datasnap? I have a database MySql, a Mobile application in Delphi Seattle with a datasnap server, the connection works and I can get the data from the bank and play pro mobile, but my question is: I need to login with Client 1 and it will only appear the data of this client, hence I click on item 1 of it and the data of item 1 appears and I need to make changes to this item, save and send to mysql again. I do not know how to do this method in datasnap and call on mobile

    
asked by anonymous 28.03.2016 / 14:54

2 answers

0

Your webservice connects to your database and you use SQLconnection , SQLDataset , and Datasetprovider . In Commandtext of your sqldataset you entered something like

Select * from tabela where id =:id

In your mobile application, in your datamodule you put SQLConnection , drive datasnap, DSProviderconnection and even ClientDataSet , in the object inspector of ClientDataSet you set RemoteServer pro tu DSProviderConnection e no ProviderName set your datasetprovider there of your webservice .

In Params you create a new paramenter with the name of id , give it a value of 1 just to test, right-click on your clientdataset and click on FieldsEditor , click on right click on the white area of the new window and click on Add Fields , if you load all the fields of the table it is signal that everything is ok by passing correct parameter, delete the value of the parameter created in your clientdataset .

When you need to make a request using paramentro, just use:

 ParamByName('id').AsInteger := 1; 

To write the changed data that has been uploaded is that old story of Post and ApplyUpDates()

Hope it was useful

    
05.10.2016 / 14:47
-1

I do not know if I understood your question well, it's a bit confusing, but if that's what I understand, it's a very simple problem to solve, alias very primary. the client data x has to be parameterized somehow select * from table where client =: client

When you log in, you get some data from the client type id or anything and use it as a paramenter.

function getPefilUsuario(aUsuario, aSenha: string): Boolean;
begin
  with FQry_Pefil do
  begin
    Close;
    Params[0].AsString := UpperCase(aUsuario);
    Params[1].AsString := UpperCase(aSenha);
    Open;
    Result := (FQry_Pefil.RecordCount > 0);
  end;

If it's not that I'm sorry you're really confused the question

    
19.08.2016 / 04:46