Creating new records in a databaseThere are two basic approaches to adding new records to a database. In the direct approach, the viewer fills out some fields of a form, clicks on a form submit button, and the record is added. The Add Record action supports this direct approach. In the second approach, the viewer is usually viewing a database record on a form and is presented with the possibility of updating that record. In addition, the viewer is presented with the possibility of creating a copy of that record's data or creating a new record from scratch using the same style of form. The viewer, in this case, selects such a choice, gets a new form page to be filled out, and then clicks a submit button to add the record. The Clear Form Data and Copy Form Data actions are used on the initial page to support this approach, followed by either the Update Record or Add Record actions on the second page. To set up a form for direct record update:
You can have more than one submit button on the form, each with a different action. Usually, when a form is being displayed for creating a new record, you want the fields to be blank. Binding them to content source fields causes the values from the database to appear. (See Creating a blank form for adding new records to a database for details on how to make the form blank.)
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. |