Chapter Windows Database Applications 2 Universal Data Access UDA Microsoft’s strategy for accessing data for multiple providers Goal is to access any type of data from any applicatio
Trang 1Chapter
Windows Database
Applications
2
Universal Data Access (UDA)
Microsoft’s strategy for accessing data for multiple providers
Goal is to access any type of data from any application on any type of computer
OLEDB
Technology designed to implement the UDA concept
Standardized interface that allows reference to data from any source using the same
programming tools
Trang 2From DAO To ADO.NET
Data Access Objects (DAO 1-tier ) enabled programmers to access local databases in the Microsoft Jet Database Engine format, which were primarily Indexed Sequential Access Method (ISAM) files
After DAO came RDO Remote Data Objects (2-tier)
After RDO came ADO ActiveX Data Objects (ADO 1 to n-tier)) These data access technologies were designed for a client / server paradigm However the tendency of distributed computing forced the development
of a new technology to solve the problems of data manipulation on a n-tier architecture ADO.NET is the evolution of ADO and its components have benn designed to function properly on a n-tier architecture
5
ADO.NET
ActiveX Data Objects ADO
ActiveX Data Objects ADO
ADO.NET latest database object model
Allows CSharp programmers to use a standard set
of objects to refer to data from any source
.NET approach uses disconnected datasets with
common data representation (data types) from
multiple sources
6
ADO.NET Components
Data Providers – manipulate the data using SQL statements
or stored procedures
SQLClient for SQL Server
OleDbClient for all other database formats
An ODBC provider is available for download
Trang 3Data Provider Objects
Connection object (OleDbConnection)– link to a data source
DataAdapter object(OleDbDataAdapter) – handles retrieving and updating data in a DataSet object
Command object (OleDbCommand) – storeprocedure and executes SQL statements
DataReader object (OleDbDataReader) –
for read-only access
8
ADO.NET Components
DataSet Objects holds a copy of the data in
memory
Dataset objects can be populated with data from many sources
Regardless of the data source, code handles DataSet objects the same
Dataset objects hold one or more DataTable objects
CÀI ðẶT MSDN (Help)
Mô Hình Kết Nối
Data Adapter
DataSet
Web
Form WindowsForm
Windows Form
Data Adapter DataSet
Windows Form
DataSet DataView
Windows Form
Data Reader
Trang 4NET Data Provider Objects
SelectCommand
InsertCommand
UpdateCommand
DeleteCommand
Connection
.NET Data Provider
Command
Data Adapter
DataReader
11
The DataSet Object Model
DataSet
DataTable Collection
DataTable
DataRowCollection
DataColumnCollection
ParentRelations
ChildRelations
ConstraintCollection
DataView
DataRelationCollection
12
The DataSet Object Model
Trang 5DataTable Characteristics
A primary key field (or combination of fields) uniquely identifies each record
A relational database contains multiple tables
Relationships between tables are established using
a foreign key
14
Multitier Applications
Data Retrieval Data storage Business Object
Validation Calculations Business logic Business rules
User Interface
Forms
Controls
Menus
Data Tier Business Tier
Presentation Tier
Multitier Applications
Presentation tier the user interface
Business tier class(es) that handle the data
Calculations
Validation to enforce business rules
Data tier retrieving and storing the data in a
Trang 6Display the DataSet in the DataGrid
17
Display the DataSet in the DataGrid
18
Display the DataSet in the DataGrid
Trang 7Display the DataSet in the DataGrid
Connection
Data Adapter
Data
Source
DataSet
Web
Form WindowsForm
Presentation Tier
Data Tier