共用方式為


Updating a Table in a View

You can use either local or remote views to update your tables.

Sending Updates to Tables

In the 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.

Making a Table Updateable

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 updateable. You must have a key field defined for a table in order to make any fields in that table updateable. If fields are not marked as updateable, 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 updateable

  • In the Update Criteria tab, click the updateable ("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 updateable.

To make all fields updateable

  • 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

Updating Data in a View | Update Criteria tab | Displaying the Structure of a View | Updating Multiple Tables in a View | Creating Queries | Creating Views | Displaying Data with Views | Table Creation | Programming for Shared Access