Upgrading the Client

Porting the client application to DataSnap 2009 is generally easier than porting the server. The core step is to remove the connection components (my demo had three, as it let users experiment with the various connectivity options) and replace it with an SQLConnection and a DSProviderConnec-tion, and make the ClientDataSet component refer to this new remote connection component.

The only specific code I had to change was the call to the Login server method. This took place in the OnAfterConnection of the connection component, and I've now moved it to the corresponding event of the SQLConnection component:

procedure TClientForm.SQLConnection1AfterConnect(

Sender: TObject); begi n

  • was: ConnectionBroker1.AppServer.
  • Login (Edit2.Text, Edit3.Text);

SqlServerMethod1.ParamByName( 'Name').AsString : =


  1. ParamByName( 'Password').AsString : =
  2. Text; SqlServerMethod1.ExecuteMethod; end;

What this call does is to pass client login information to the server. The server validates the information and, only if it succeeds, it will let the provider expose its data. The password check is trivial, but the approach could be interesting. This is the Login method on the server:

procedure TAppServerPlus.Login(

const Name, Password: WideString); begi n if Password <> Name then raise Exception.Create (

'Wrong name/password combination received'); ProviderDepartments.Exported := True; ServerForm.Add ('Login:' + Name + '/' + Password); end;

Notice that in case the server returns an exception this will be clearly displayed (indicating where it comes from, Remote error) on the client side:

Thinplus2009cfent -â– -

Remote error: Wrong name/password combination received.

Was this article helpful?

0 0
Project Management Made Easy

Project Management Made Easy

What you need to know about… Project Management Made Easy! Project management consists of more than just a large building project and can encompass small projects as well. No matter what the size of your project, you need to have some sort of project management. How you manage your project has everything to do with its outcome.

Get My Free Ebook

Post a comment