次の方法で共有


How to: Share 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 Query and View Designers.

    -or-

  • Use the CREATE SQL VIEW Command 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

Tasks

How to: Optimize View Performance

How to: Optimize Filters and Joins

How to: Create Queries (Visual FoxPro)

How to: Test a Connection for Availability