The data component of the .NET Framework (namely ADO.NET) works with two layers. These layers are called the connected and the disconnected layer. As you can guess, their names refers to the fact whether they are actually connected to a data source.
But before we dig into their details, let’s see what do they have in common – the fundamentals of ADO.NET.
To connect to a data source, your very first step will be to chose a provider. There are four providers built in the .NET Framework 3.5, these are the OleDbProvider, the OdbcProvider, the SqlProvider and the OracleProvider. You typically set the provider in the connectionString section of the web.config. Each provider declares four classes to manipulate data, these are:
- Command: represents a database command (stored procedure or ad hoc).
- Connection: represents a database connection. You typically refer to the web.config connectionStrings section to retrieve one.
- DataReader: provides a read-only, forward-only way to get data from a database.
- DataAdapter: lets you fill data objects of the disconnected layer, and write back the changes to the database.
Each of these classes gets the prefix of the provider name. So for example, when you want to connect to a SQL database, you will use a SqlConnection class to do so. Let’s take a closer look to these classes: