开发者

How do I get a remote SQLConnection for TDSProviderConnection.SQLConnection?

开发者 https://www.devze.com 2022-12-18 06:59 出处:网络
With DataSnap 2009 i seems to be possible to use a remote database connection in the client datamodule, usi开发者_Python百科ng a TDSProviderConection and an associated TSQLConnection. The client side

With DataSnap 2009 i seems to be possible to use a remote database connection in the client datamodule, usi开发者_Python百科ng a TDSProviderConection and an associated TSQLConnection. The client side is easy to set up, I drop a TSQLConnection on the form and link it to the TDSProviderConnection component.

But what are the steps in the remote datamodule on the server side to provide the 'real' SQLConnection to the client? I have a server module which inherits from TDSServerModule, a TDSTCPServerTransport, a TDSServer and a TDSServerClass component. How do I link these to a server side TSQLConnection?


In fact the easiest way to access the serverside database connection from DataSnap 2009 client is to use just a TSQLConnection component. Set its "Driver" property to "DataSnap" and in the "ServerConnection" subproperty specify a server method that returns a "TDBXConnection" reference. You can manually add such a server method to your remote data module. It is easier to use a build-in "DSAdmin.GetConnection" server method and just specify then name of the DBExpress connection as it appears in Data Explorer on the serverside or is specified in DBXConnection.ini file. The gotcha is to use double quotes around connection name. For example if you have an InterBase connection named "IBEMPLOYEE" in Data Explorer, just enter into "ServerConnection" the following string:

DSAdmin.GetConnection("IBEMPLOYEE")

and set "Connected" property to "true".

In this scenario you do not need to anything special on the DataSnap server. In fact you do not even need a server module as you are using a built-in one.

HIH

Pawel

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号