Search code examples
delphisessionconnectionremobjectsdataabstract

How to use a connection to database saved in a session in DataAbstract/RemObjects?


In the DataAbstract sample application "Old\Connection By User" the procedure "AcquireHoldButtonClick" creates a connection to the database and stores a reference in the user's session variable. I plan to use such a mechanism but fail to understand where and when I will need to access this session variable to provide the correct connection for that user.

As an example, when I call the ApplyUpdates method on the client, the server will have to access the connection in the session but I don't know which event I have to catch from the server to achieve that ?


Solution

  • Found it: DataService.OnBeforeAcquireConnection

    "This event is triggered when the Data Abstract service property AcquireConnection is set to TRUE and the service is about to ask the connection manager for a database connection. It allows you to override the ConnectionName property value that was set at runtime to connect to a different database, or is left blank to use the default connection in the list of those owned by the connection manager."

    http://wiki.remobjects.com/wiki/Authentication_and_application_security_%28Delphi%29