Chapter 7. Data Access and Data Binding

While writing simple applications without ever accessing data from a backend data store is certainly possible, most applications will, at some point, need to do so. Fortunately, the .NET Framework provides a rich set of classes designed to simplify the process of reading and writing data to both SQL Server and other backend data stores. These classes are collectively referred to as ADO.NET.

This chapter provides an overview of ADO.NET and the various tasks it facilitates from reading data with the SqlDataReader class to updating data with the DataSet and SqlDataAdapter classes. The chapter also discusses reading from and writing to XML files and provides examples of binding retrieved data to ASP.NET Server Controls.

Data Access and Architecture

Almost everyone agrees that in all but the smallest applications, it is important to avoid performing data access directly from the ASP.NET Web Forms themselves. Accessing data directly from within a Web Form inherently ties the user interface code to the database and table schema that currently exist, making it more difficult to reuse data-access code and maintain the user interface code and backend data.

To keep the code as simple and straightforward as possible, the examples in this chapter perform data access directly from the pages. In a production application, this code should generally reside in either data-tier or business-tier components, which should return XML, a dataset, or some other database-independent structure to the presentation tier for data binding. Remember that you should always perform data calculations and modifications on a tier other than the presentation tier.



ASP. NET in a Nutshell
ASP.NET in a Nutshell, Second Edition
ISBN: 0596005202
EAN: 2147483647
Year: 2003
Pages: 873

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net