The connection to the underlying data source is not yet open when the event handler delegate is called.
Therefore, you cannot directly cancel the Update database operation by calling the Cancel method on the Db Command object that is exposed by the Sql Data Source Command Event Args object.
The example shows how you can use a Db Transaction object to add transaction context when using the Sql Data Source control to update data.
Below illustrates a crude “sequence” that assigns an incrementing counter to a primary key column: It should be noted that for real “incrementing sequence” behavior, the built-in capabilities of the database should normally be used, which may include sequence objects or other autoincrementing capabilities.
For primary key columns, SQLAlchemy will in most cases use these capabilities automatically.
The following code example demonstrates how to display data that is retrieved from a Microsoft SQL Server database in a Drop Down List control and update the record using a Text Box control.
Above, the value “12” will be bound as the column value during an INSERT if no other value is supplied.