Displaying Data with Views
After you've created a view, you can use the view to display and update data. You can also modify the properties of a view to increase view performance. You treat a view like a table:
- Open the view with the USE command and include the name of the view.
- Close the view with the USE command.
- Display view records in a Browse window.
- Display open view aliases in the Data Session window.
- Use the view as a data source, such as in a text or Grid control, form, or report.
You can use a view through the Project Manager or the language.
To use a view
In the Project Manager, select a database, choose the name of the view, and then choose Browse to display the view in a Browse window.
-or-
Access the view programmatically with the USE command.
The following code displays product_view
in a Browse window:
OPEN DATABASE testdata
USE product_view
BROWSE
When you use a view, the view is opened as a cursor in its own work area. If the view is based on local tables, Visual FoxPro also opens the base tables in separate work areas. The base tables for a view are the tables accessed by the SELECT - SQL statement you include in the CREATE SQL VIEW command when you create a view. In the previous example, using product_view
automatically opens the products
table as well.
Data Session window displays the view and its base table
When a view is based on remote tables, the base tables are not opened in work areas. Only the name of the remote view appears in the Data Session window.
See Also
Accessing Remote Data | Limiting the Scope of a View | Creating Queries | Opening Multiple Instances of a View | Displaying the Structure of a View | Customizing Views