Partilhar via


Sharing Connections for Multiple Remote Views

You can use one active connection as the information pipeline for multiple remote views by sharing a connection. When you share an active connection, you:

  • Reduce the number of connections on a remote server.
  • Reduce costs for connections to servers that charge on a per-connection basis.

You share connections by setting the view definition to use a shared connection upon activation. When the view is used, Visual FoxPro connects to the remote data source using the existing shared connection (if any). If a shared connection isn't in use, Visual FoxPro creates a unique connection when the view is opened, which can then be shared with other views.

Only one active instance of a named connection definition is shared during a Visual FoxPro session. If multiple instances of the same connection definition are active, the first instance to be used as a shared connection becomes the designated shared connection. All views that use that connection definition and employ connection sharing will access the remote server through the designated shared connection.

Connections other than the designated shared connection are not shared. Connection sharing is not scoped to sessions.

To share a connection

  • From the Tools menu, choose Options and select the Remote Data tab; then select Share connection in the Remote view defaults area and choose OK.

    -or-

  • Use the View Designer.

    -or-

  • Use the CREATE SQL VIEW command with the SHARE clause.

The following code creates a view that, when activated with the USE command, shares a connection:

CREATE SQL VIEW product_view_remote ;
   CONNECTION remote_01 SHARE AS ;
   SELECT * FROM products
USE product_view_remote

See Also

Optimizing Filters and Joins | Creating Queries | Testing a Connection for Busyness | Setting the Maximum Number of Records Downloaded | Optimization of View Performance