Updating database table datagridview
Fortunately, the Configure Data Source wizard provides an option to have the statements checkbox will only be checkable if the table selected has a primary key and the primary key column (or columns) are included in the list of returned columns.
The Use optimistic concurrency checkbox, which becomes selectable once the Generate statements to provide optimistic concurrency control.
When the Sql Data Source control s method is invoked either programmatically or automatically from a data Web control a connection to the database is established, the parameter values are assigned to the query, and the command is shuttled off to the database.
The results are then returned as either a Data Set or Data Reader, depending on the value of the control s value has been specified, the Enable Inserting, Enable Editing, or Enable Deleting option in the corresponding data Web control s smart tag will become available.
Figure 5: Clicking the Delete Button in the Grid View Invokes the Sql Data Source s SQL statements can be specified through the Properties window or the control s declarative syntax.
However, this approach requires that we manually write out the SQL statements by hand, which can be monotonous and error-prone.
In previous tutorials we learned how the Object Data Source control allowed for inserting, updating, and deleting of data.
After checking the Generate statements checkbox, click OK to return to the Configure Select Statement screen, then click Next, and then Finish, to complete the Configure Data Source wizard.
An Overview of Inserting, Updating, and Deleting examined using the Object Data Source to facilitate inserting, updating, and deleting with the Grid View, Details View, and Form View controls.
Alternatively, the Sql Data Source can be used in place of the Object Data Source.
As we'll see in this tutorial, these statements can be created manually or can be automatically generated by the Sql Data Source s Configure Data Source wizard.
Note Since we ve already discussed the inserting, editing, and deleting capabilities of the Grid View, Details View, and Form View controls, this tutorial will focus on configuring the Sql Data Source control to support these operations.