Visual FoxPro makes it possible for you to share a connection handle for a remote data connection. Sharing a connection handle can be desirable when you want to manage SQL Server connections and server resources better by reducing the number of connections.
By default, Visual FoxPro creates a new connection handle each time a remote data connection is created. However, when specified, Visual FoxPro can use an existing connection and associate the new statement with it. This creates a new statement handle and Visual FoxPro handle; however, the associated connection handle is the same.
There are three types of handles associated with a remote data connection. The following table describes these handles.
Shared Connections for Remote Views
A remote view can use a shared connection handle by including the SHARE keyword in the CREATE SQL VIEW command. If a shared connection is available, Visual FoxPro uses it to create a new statement handle and Visual FoxPro connection handle. If a shared connection is unavailable, Visual FoxPro creates a new, shared connection that other views can use.
Shared Connections for SQL Pass-Through
You can create a new connection that can be shared by including the lShared parameter in the SQLSTRINGCONNECT(В ) command. The SQLSTRINGCONNECT(В ) command always creates a new connection, statement, and Visual FoxPro connection handle.
Including the lShared parameter in the SQLCONNECT(В ) command also creates a new connection that can be shared; however, including the nStatementHandle parameter causes SQLCONNECT(В ) to use a currently shared connection and creates only a new statement handle and Visual FoxPro connection handle.