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

Asked

Viewed 1,520 times

1

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

  • try to pass as parameter in your method

  • But I create the method with parameters on the server, so how do I receive these parameters on the mobile? type, have to appear the data in each field on mobile and the user will change this data, save and send back to Mysql database. I don’t know how to do it right

  • Do one method on the server to return a Tdataset and another to Receive a Tdataset. Ex.: Getclientes(): Tdataset and other Setclientes(dtsDados: Tdataset);

2 answers

1

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

Select * from tabela where id =:id

In your mobile application, in your datamodule you put SQLConnection, datasnap drive, a DSProviderconnection and still a ClientDataSet, in the inspector Object of the ClientDataSet you set the RemoteServer for your DSProviderConnection and in the ProviderName set your datasetprovider there of your webservice.

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

When you need to make a request using parameter just use:

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

To save the changed data that was loaded is that old story of Post and ApplyUpDates()

I hope you’ve been helpful

-1

I do not know if I understand your question is a bit confused, but if it was what I understood is a very simple problem to solve , very primary alias. x client data has to be parameterized in some example select * from Where client =:client

when logging in.

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 sorry I’m really confused the question

Browser other questions tagged

You are not signed in. Login or sign up in order to post.