decorative banner

Updating records in a database


    You can create forms that display a single record or more than one record. To create a form showing more than one record, you can, for example, place form fields in a table row, bind them to fields of a content source, and turn on Replace Rows for the table so that the table is filled with values from different records, one record going into the fields in each table row.

    GoLive keeps track of which record is associated with each field on the form so form Update actions can send data from the form to the appropriate record even if more than one record is shown in the table. When an Update action is performed, all data from the form is written to the database, updating whichever records and fields are present on the form. This includes hidden fields that are bound to the content source. Form fields that are not bound to the content source and other page elements that are bound do not participate in the database update action.

    After the update action is performed, the next page displayed can be either the current page, a different page selected if the update operation is successful, or a different page selected if the update operation fails.

To set up a form for a database update:

  1. Create the form and fields for the display and update of the current database data.
  2. Add a content source to the page connected to the database from which data will come and to which the updates are to go.
  3. Bind the form elements to fields in the content source.
  4. Add a form Submit Button to the form and select it. It is usually a good idea to set the label to a string appropriate to the function of the page.
  5. In the Dynamic Bindings palette, set the form action to Update Record. This will be a second level menu item under "ADO Database" for ASP, "MySQL" for PHP, and "JDBC" for JSP.
  6. Set the Content source to the content source that references the table to which the record should be added. This must be the same content source to which form elements are bound. There must be at least one form field bound to that content source.
  7. If the design of the interaction dictates that the next page the user sees after pressing the form submit button is the same page, you do not need to set the redirect URLs. If not, you can define the next page to be displayed after the record or records are updated, and the next page to be displayed if there is an error updating the record or records.
  8. You can have more than one submit button on the form, each with a different action.

    Be very careful of how fields not present in the form are handled in the database. If a field is not on the form, it must have allow zero length, not required, or default values specified. Otherwise, difficult-to-diagnose errors may result because the database will reject the update.

    Make sure you have set up proper database permissions for the Web server to make updates or for the identity specified in data source. Remember that when your action is being processed on the server, the Web server's identity is used to validate file access. The Web server's identity is also used to validate database access unless there is another identity specified as part of the data source.