How to: Update a Table in a View

JavaScript Editor js editor     Web development 



Main Page

You can use local or remote views to update the base tables in the remote data source. In the Update Criteria Tab, View Designer, the Update Criteria tab allows you to control how the changes you make to remote data (updates, deletes, and inserts) are sent back to the remote data source. You can also enable and disable updating for specific fields in the tables and set the SQL update method appropriate to your server.

Note:
The local base tables that open automatically when you use a view are not automatically closed when you close a view; you must explicitly close them. This is consistent with the SQL SELECT command.

Making a Table Updatable

If you want to have the changes you make to the local version of a table sent back to the source table, you need to set the Send SQL Updates option. You must set at least one key field to use this option. If the table you select has a primary key field defined and you have selected it in the Fields tab, the View Designer automatically uses the primary key field for the table as a key field for the view.

To enable updating of source tables

  • In the Update Criteria tab, set the Send SQL updates option.

Setting Key Fields

When you first open a table in the View Designer, the Update Criteria tab shows which fields in the table are defined as key fields. Visual FoxPro uses key fields to uniquely identify the update records in remote tables that you have modified locally.

To set a key field

  • In the Update Criteria tab, click the key column next to the name of the field.

If you have changed the key fields and want to restore them to the original setting in the source table, choose Reset Key. Visual FoxPro will check the remote tables and use the key fields from those tables.

Updating Specific Fields

You can specify that only certain fields in any given table are updatable. You must have a key field defined for a table in order to make any fields in that table updatable. If fields are not marked as updatable, users can make changes to the field in a form or Browse window, but these changes are not sent to the remote table.

To make a field updatable

  • In the Update Criteria tab, click the updatable ("pencil") column next to the name of the field.

Updating All Fields

If you want to be able to make changes to all the fields in a table, you can set all the fields in a table as updatable.

To make all fields updatable

  • In the Update Criteria tab, choose Update All.

    Note:
    You must have a key field defined in a table in order to use Update All. Update All does not affect key fields.

See Also



JavaScript Editor js editor     Web development