Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Datasnap Client with params


This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 0
David Smith

Posts: 7
Registered: 6/15/14
Datasnap Client with params  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 7, 2017 3:17 AM
Hi - my experience with Datasnap technology is very low as I'm sure you will see from my question. However I'm keen to get something working that demonstrates to my colleagues the benefit of Delphi and this technology.
So I have created a very simple Datasnap server built using Delphi Berlin that has a parameterised query that selects clients from an Oracle database based upon a SELECT * FROM CLIENTS WHERE SURNAME LIKE ' statement.

I then created a simple Multi-Device client app that connects to the Data Snap server locally over the standard port 211. I'm using a TSQLConnection, TClientDataSet, TDSProviderConnection and the results are returned to the ClientDataSet and presented in a TListBox. All good so far.

By the way the back-end Oracle db has tens of thousands of clients so I don't really want from a user or security perspective to retrieve all records and eventually will limit this further but for now using a filter on surname seems sensible as a proof of concept.

I have placed a TEdit and TButton on the form so that the user can enter a surname and hit the button to retrieve the relevant clients. However this is where the problem arises. The on-click code for the button is:

with TClientDataSet1 do
begin
if active then close;
params.ParamByName('ThisName').asstring := Uppercase('%' + edtClient.Text + '%');
open;
showmessage('Records returned = ' + IntToStr(RecordCount));
close;
open;

end;

What I seem to have to do to show the results of the current edit box contents are to open and close the TClientDataSet twice - in other words the first 'Open' call doesn't seem to do anything 'different' and the showmessage shows the number of records returned previously. Adding the 2nd close and open seems to make it work.

So it works - but it doesn't seem logical or 'nice' so anyone please, do you know why I'm having to do this?

Many thanks in anticipation and best regards

David
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02