DataTable, DataSet, and Friends
Although the data-binding architecture is
flexible enough to bind to any property of any object, the .NET
Framework provides a group of classes (part of
ADO.NET) that have
much more extensive data-binding support. At the center of this
family are the DataSet
and
DataTable
classes in the
System.Data
namespace. These form the basis for
the disconnected use of data from a database, and they are designed
to allow flexible presentation of data while making efficient use of
server resources.
All presentation of data from a database in Windows Forms is based around a disconnected model—clients connect to a database and retrieve all the data they require in a single step. They do not hold onto any server-side resources (such as cursors) after this data has been retrieved, and can therefore release their connection to the database. (In practice, the connection will normally be returned to a pool rather than being freed completely.) This is a departure from previous data-binding models, where disconnected operation was strictly optional. This new model reduces the workload on the server, because at any given instant it has to deal with fewer clients, thus improving the scalability of the system.
The DataTable
class allows a snapshot of part (or
all) of a database table to be held on the client. The
DataSet
class can hold any number of
DataTable
objects, and can also contain
information about relations between these tables.
(Relations are represented as
Get .NET Windows Forms in a Nutshell 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.