The previous chapter introduced LINQ (Language-Integrated Query) and showed how it works with objects. This chapter introduces ADO.NET, which is the traditional way of accessing databases with previous versions of C# and .NET, and then it introduces LINQ over DataSet, which is the version of LINQ that cooperates with ADO.NET.
All examples in this chapter use the SQL Server Northwind example database (except where specifically noted). See the previous chapter for instructions on installing the SQL Server Northwind example database.
In particular, this chapter looks at the following:
An overview of ADO.NET and the structure of its main classes.
Reading data with a
DataReader and with a
Updating the database, adding records, and deleting records.
Working with relationships in ADO.NET.
Reading and writing XML documents in ADO.NET.
Executing SQL commands directly from ADO.NET.
Executing stored procedures from ADO.NET.
Querying ADO.NET objects with LINQ over DataSet.
After an overview of ADO.NET, you will learn the concepts behind it. Then you can create some simple projects and start using the ADO.NET classes.
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 such as Microsoft SQL Server and Microsoft Access, as well as other databases and even nonrelational data sources. ADO.NET is integrated into the .NET Framework ...