- Learn what ADO.NET is.
- Understand what a data provider is.
- Understand what a connection object is.
- Understand what a command object is.
- Understand what a DataReader object is.
- Understand what a DataSet object is.
- Understand what a DataAdapter object is.
ADO.NET is an object-oriented set of libraries that allows you to interact with data sources. Commonly, the data source is a database, but it could also be a text file, an Excel spreadsheet, or an XML file. For the purposes of this tutorial, we will look at ADO.NET as a way to interact with a data base.
As you are probably aware, there are many different types of databases available. For example, there is Microsoft SQL Server, Microsoft Access, Oracle, Borland Interbase, and IBM DB2, just to name a few
ADO.NET allows us to interact with different types of data sources and different types of databases.
Since different data sources expose different protocols, we need a way to communicate with the right data source using the right protocol. Some older data sources use the ODBC protocol, many newer data sources use the OleDb protocol, and there are more data sources every day that allow you to communicate with them directly through .NET ADO.NET class libraries.
ADO.NET includes many objects you can use to work with data.
The SqlConnection Object
A connection object is used by command objects so they will know which database to execute the command on.
The SqlCommand Object
The SqlDataReader Object
The DataSet Object
The SqlDataAdapter Object
A data adapter contains a reference to the connection object and opens and closes the connection automatically when reading from or writing to the database.
DataSet objects are in-memory representations of data. They contain multiple Datatable objects, which contain columns and rows, just like normal database tables. You can even define relations between tables to create parent-child relationships. The DataSet is specifically designed to help manage data in memory and to support disconnected operations on data,
Many data operations require that you only get a stream of data for reading. The data reader object allows you to obtain the results of a SELECT statement from a command object. For performance reasons, the data returned from a data reader is a fast forward-only stream of data. This means that you can only pull the data from the stream in a sequential manner. This is good for speed, but if you need to manipulate data, then a DataSet is a better object to work with.