ADO.NET Components
•Database Classes
–Access and update databases
–Uses “Managed Provider” to connect to DB
•Data Classes
–Hold data in-memory, disconnected from
database
–User defined structure. Does not have to
map to DB.
–“DataSet” is the key class
Database Classes
Execute database commands and make
results available.
Connection: a database connection
Command: what to execute, generally SQL
DataReader:
Read-only, forward-only cursor.
DataAdapter:
Connects a DataSet to
the database and can resolve changes back to DB
CommandAdaptor: Automatically generates
Insert/Update/Delete commands from a Select command (expensive!)
Connections are always made thru “Managed
Providers”
Essentially the next version of OLEDB
Native, .net managed data-access components
Remember: Managed means .net
handles memory management, security etc.
Only two Managed Providers at time of
writing:
–Microsoft SQL Server, included with .net
–Microsoft OLEDB, included with .net
•Enables developers to work with existing
OLEDB drivers until managed versions available.
Data classes: DataSet
•Hold a disconnected, in-memory version of
the data
•Designed to hold >=1 table of data at
a time
–improvement over ADO where a RecordSet
could only hold a single table.
•Can model relationships between those
tables and enforce them on the client
•Save as XML with schema
•Can design visually in Visual Studio or
use DataSet
class directly – see next slide for details
•May or may not be direct representation
of database
–Note: By default, DataAdapter can
only automatically insert/update/delete direct representations of database
0 comments:
Post a Comment