Share via


Visual InterDev

In addition to simply displaying data from a database, you can create Web pages that allow users to modify data — update existing records, add records, and delete records. You build data modification into your application by using the , which creates a recordset — a virtual table that users can navigate in and update. Modifications are made to the recordset and then passed to the underlying database.

Alternatively, you can display records on your page using a recordset, and then call stored procedures to perform actions such as updating, inserting, and deleting. The method for performing the updates is the same whether you use a recordset or a stored procedure. For details about binding a Recordset control to stored procedures, see Executing Database Commands Using the Data Environment.

No matter what method you use, you must first be sure that it will be possible to update the database at all. Factors to consider are:

  • **Permissions   **Many databases require explicit permission for updates. Even if you as the developer have permission to make updates, you must be sure that your Web application's users will also.

  • **Sufficient data   **As a rule, the recordset must include sufficient information for the database to find the correct record to modify — usually the primary key or a unique index value. In addition, only fields that are part of the recordset can be updated. For example, a recordset might include an employee's ID, first name, and last name, even though the employee table has many more fields. In that case, you would only be able to update those three fields or provide only those three fields when adding a new record.

  • Updateable data source   If you are updating via the recordset, it must have a Keyset or Dynamic cursor type and a lock type that is not read-only. In addition, the recordset must be based on a database object that you can update. For example, if the recordset is based on a view that contains no primary key or unique index, it cannot be updated, regardless of what cursor type you have selected. The exact constraints depend on how you generated a result set and on the features of the database you are using. For details about setting recordset options, see the .

    Note   If you are using stored procedures to update the database, the cursor type of your recordset is less important, because updates are not passed through the recordset.

For detail about how to update databases, see the topics listed in the following table.

To See
Get the values of the current record Getting Values from the Current Record
Update records Updating Records
Delete one or more records Deleting Records
Add new records to the database Adding Records