Accessing and Updating Data in ASP.NET 2.0: Programmatically Accessing Data using the Data Source Controls
Posted by: 4GuysFromRolla.com Headlines,
on 11 Apr 2007 |
View original | Bookmarked: 0 time(s)
Working with data in ASP.NET version 1.x required writing data access code.
This involved establishing a connection to the database, specifying the SQL command, and then executing the command.
ASP.NET 2.0's data source controls greatly simplifies this process by
encapsulating the data access pattern within a Web control construct. As such, data can be retrieved or modified and bound
to a Web control without writing a single line of code. We explored the essentials of declarative data binding earlier in
this article series in the Data Source Control Basics
and Accessing Database Data articles.
In addition to being used declaratively, the data source Web controls can also be accessed programmatically. It is possible
to add a SqlDataSource or AccessDataSource control to a web page, specify SELECT,
INSERT, UPDATE, or DELETE queries, and then to programmatically execute one of
the control's SQL commands. Such an approach is useful when you need to work with data programmatically, but want to avoid
having to write the boilerplate data access code. In short, using the data source controls in this manner allows for data
to be accessed programmatically with a single line of code.
In this article we will examine how to use the SqlDataSource control to programmatically retrieve, insert, and delete data.
Read on to learn more!
Read More >