Datasheet

Displaying Data on the Web
19
ADO.NET Architecture
You now know that ADO.NET draws on a long history of data access. Almost inevitably, this means
that there is quite a lot to learn. Thankfully, Microsoft has put a great deal of thought into its new data
access technology, making it more logical and structured than previous attempts, while still providing a
wealth of features.
ADO.NET is made up of a collection of objects, some of which are entirely new, and others of which
have evolved from ADO. The main difference between these and their predecessors is that there is
now generally only one way to accomplish a task – ADO was a little infamous for providing several
means to exactly the same end!
The next few pages are concerned with taking a look at the main ADO.NET objects, and how they
cooperate to provide data manipulation. Laid out below is a diagram of the five main object types that
you'll be dealing with when you use ADO.NET:
Data Store
Connection
ConnectionString
Command
Connection
CommandText
CommandType
DataAdapter
SelectCommand
UpdateCommand
InsertCommand
DeleteCommand
DataSet
DataReader
If we work our way back from the database, taking the objects one by one, we can see how these objects
work together, and what functions they perform:
The connection object is the route through which all instructions to (and results from) the data
store are sent. The user can specify which database to connect to, what authentication to use,
and so on.
The command object contains the instructions that specify what information should be sent to
(or retrieved from) the database. It also contains a link to the connection that it's going to use.
The data reader object provides a way of 'getting at' the information that's been retrieved by
the command object. The information is provided on a read-only basis – so it can't be edited –
and only one item of data is read at a time. Data readers provide an efficient (if inflexible) way
of processing large amounts of data; they are sometimes described as providing connected
access, since the connection with the database must remain open for as long as the data reader
is in use.