Databases and ADO.NET

This chapter shows you how to access relational databases with C#. Because this is a C# book, this is a largely code-based chapter, showing how ADO.NET (the data access classes in .NET) is structured and how to accomplish basic data access with C# code. In the next chapter, you look at how Visual Studio 2005 can generate much of the data access code for you and how to use that generated code in many common business situations. However, it is important that you have the background information necessary to understand what the wizard-generated code is doing for you and how you can combine your own code with what Visual Studio 2005 generates to provide maximum flexibility and productivity when accessing relational data. That background is provided in this chapter. In particular, you look at:

  • An overview of ADO.NET, and the structure of its main classes
  • Reading data with a DataReader and with a DataSet
  • Updating the database, adding records and deleting records
  • Working with relationships in ADO.NET
  • Reading and writing XML documents in ADO.NET
  • Direct execution of SQL commands from ADO.NET
  • Execution of stored procedures from ADO.NET

First, you get an overview of ADO.NET and learn the concepts behind it. Then you can create some simple projects and start using the ADO.NET classes.

What Is ADO.NET?

ADO.NET is the name for the set of classes you use with C# and the .NET Framework to access data in a relational, table-oriented format. This includes relational databases ...

Get Beginning Visual C#® 2005 now with the O’Reilly learning platform.

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