Chapter 26

Data Access

This chapter discusses how to access data from your C# programs using ADO.NET. The following details are covered:

  • Connecting to the database — You learn how to use the SqlConnection and OleDbConnection classes to connect to and disconnect from the database.
  • Executing commands — ADO.NET has command objects that can execute SQL commands or issue a call to a stored procedure with optional return values. You learn the various command object options and see how commands can be used for each of the options presented by the Sql and OleDB classes.
  • Stored procedures — You learn how to call stored procedures with command objects and how the results of those stored procedures can be integrated into the data cached on the client.
  • The ADO.NET object model — This is significantly different from the objects available with ADO. The DataSet, DataTable, DataRow, and DataColumn classes are discussed as well as the relationships between tables and constraints that are part of DataSet. The class hierarchy has changed significantly with version 2 of the .NET Framework, and some of these changes are also described.
  • Using XML and XML schemas — You examine the XML framework on which ADO.NET is built.

Microsoft has also added support for Language Integrated Query (LINQ) in C# for the 3.0 release. Although this topic largely supersedes the information in this chapter, it is included here for completeness. See Chapters 28, “Manipulating XML,”29, “LINQ to XML,” and 31, “Windows Forms,” ...

Get Professional C# 2008 now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.