
TableAdapter Update Method
TableAdapters use data commands to read to (and write from) the database. The TableAdapter's initial Fill (main) query is used as the basis to create both the schema for the associated data table, and several TableAdapter commands (for example, InsertCommand, UpdateCommand, and the DeleteCommand.Update method). The TableAdapter's Update method will execute statements that were created when the TableAdapter was originally configured, but this method call will not execute any additional queries that you may have added by using the TableAdapter Query Configuration Wizard.
When you use a TableAdapter, it effectively performs the same operations with the commands that you typically perform. For example, when you call the adapter's Fill method, the adapter executes the data command in its SelectCommand property and uses a data reader such as SqlDataReader to load the result set into the data table. Similarly, when you call the adapter's Update method, it executes the appropriate command (in the UpdateCommand, InsertCommand, and DeleteCommand properties) for each changed record in the data table.
Note: |
|---|
If there is enough information in the main query when the TableAdapter is generated, the InsertCommand, UpdateCommand, and DeleteCommand commands are created by default. If the TableAdapter's main query is more than a single table SELECT statement, it is possible that the designer will not be able to generate InsertCommand, UpdateCommand, and DeleteCommand. If these commands are not generated, you may receive an error when executing the TableAdapter.Update method. |