Partager via


Selecting the Right Methods

You can use remote views, SQL pass-through, or both to create your client/server application. You can combine both methods for powerful results: use views for the majority of your data management requirements and use SQL pass-through to enhance the power of your application.

Using Views

You can use views as the core method for developing a robust client/server application. Remote views are a powerful technology; they're designed to allow you to select just the data you need from a remote server into a local Visual FoxPro cursor, which you can then use to view and update remote data. A view is basically a result set from a SQL SELECT statement.

Views are persistent: the view definition is stored in a database. View definitions have properties that you can set and then customize further for the active view cursor. Views are the best tool for data definition of an updatable result set.

You can use local views to build a local prototype, and then use an Upsizing Wizard to transform local views into remote views. For more information, see Upsizing Visual FoxPro Databases.

If your application's users want to use data for mobile work, you can employ offline views. Offline views make data portable, allowing laptop or other portable computer users to work with a stored copy of source data that they can update while they're on the road. When the user reconnects to the server, your application can easily merge offline changes into the source tables.

You might also want to use offline view technology to allow local users to work with data "offline," merging their updates at a later time. For more information, see Creating Views.

Using SQL Pass-Through

SQL pass-through technology provides you with direct access to a remote server with the Visual FoxPro SQL pass-through functions. These functions permit additional server access and control beyond the capability of views. For example, you can perform data definition on the remote server, set server properties, and access server stored procedures.

SQL pass-through is the best tool for creating read-only result sets and for using any other native SQL syntax. In contrast to a view, which is a result set from a SQL SELECT statement, SQL pass-through enables you to send anything you want to the server using the SQLEXEC( ) function. The following table lists the Visual FoxPro SQL pass-through functions.

SQL pass-through functions

SQLCANCEL( ) SQLCOLUMNS( ) SQLCOMMIT( )
SQLCONNECT( ) SQLDISCONNECT( ) SQLEXEC( )
SQLGETPROP( ) SQLMORERESULTS( ) SQLPREPARE( )
SQLROLLBACK( ) SQLSETPROP( ) SQLSTRINGCONNECT( )
SQLTABLES( )    

You can create cursors yourself using SQL pass-through technology. Though SQL pass-through provides more direct server access, it provides less persistent access than views. In contrast to views, whose definitions are stored persistently in a database, cursors created using SQL pass-through exist only for the current session. For more information, see Implementing a Client/Server Application.

Combining Views and SQL Pass-Through

The most powerful paradigm for building a Visual FoxPro client/server application combines view and SQL pass-through technologies. Because views are easy to build and provide automatic buffering and update capabilities, use views for the majority of your data management tasks. Then use SQL pass-through to accomplish specific tasks on the remote server, such as data definition and the creation and execution of server stored procedures.

See Also

Data Location on the Optimal Platform | Rapid Application Development | Client/Server Application Design | Application Creation with Accuracy and Data Integrity | Performance Enhancement through Set-Based Data Access | Client/Server Design for High Performance | Optimizing Client/Server Performance