Basic ADO.NET Features

This chapter begins with a quick look at the basics of ADO.NET and then provides an overview of ADO.NET capabilities, namespaces, and classes. It also reviews how to work with the Connection, Command, DataAdapter, DataSet, and DataReader classes. Later chapters will cover some of the more recently added ADO.NET features.

Common ADO.NET Tasks

Before jumping into the depths of ADO.NET, step back and make sure that you understand some of the common tasks you might perform programmatically within ADO.NET. This section looks at the process of selecting, inserting, updating, and deleting data.

Note
For all of the data-access examples in this chapter, you need the Adventure Works database titled AdventureWorks2012 Data File (SQL Server 2008) or AdventureWorksDW2012 Data File (SQL Server 2012). As of this writing, you can find this link at http://msftdbprodsamples.codeplex.com/releases/view/55330. You can then attach this database to your SQL Server 2012 Express instance using SQL Server Management Studio. This chapter was written using the SQL Server 2008 database file.

In addition, stored procedure SQL files required for the sample code can be found with the code download for this chapter.

Selecting Data

After the connection to the data source is open and ready to use, you probably want to read the data from it. If you do not want to manipulate the data but simply read it or transfer it from one spot to another, use the DataReader class (or one of the classes ...

Get Professional Visual Basic 2012 and .NET 4.5 Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.