Executing Insert
, Update
, and Delete
Commands
The SqlDataSource
control has methods that correspond to each of the different types of commands that it represents:
• Delete
—
Enables you to execute a SQL delete
command.
• Insert
—
Enables you to execute a SQL insert
command.
• Select
—
Enables you to execute a SQL select
command.
• Update
—
Enables you to execute a SQL update
command.
For example, the page in Listing 9.27 contains a form for adding new entries to the GuestBook database table. This form is not contained in a DataBound
control such as the FormView
or DetailsView
controls. The form is contained in the body of the page. When you click the Add Entry button, the SqlDataSource
control’s Insert()
method is executed.
Listing 9.27. ExecuteInsert.aspx ...
Get ASP.NET 4 Unleashed now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.