Transcript Document

Denis Gnatyuk
CMC department
AGENDA
Data Access Component
 Disconnected Data
 The DataSet

DataAdapter
 DataView
 Typed DataSets

2/25
BUILDING A DATA ACCESS COMPONENT
Layered design with a database class
3/25
BUILDING A DATA ACCESS COMPONENT
Open and close connections quickly
 Implement error handling
 Follow stateless design practices
 Don’t let the client use wide-open queries

4/25
DATA PACKAGE

Provides all database fields as public properties
[ C# 3.0 ]
5/25
STORED PROCEDURE
- needs to retrieve, insert, and update information
6/25
DATA UTILITY CLASS
-
performs the actual database operations
7/25
CONCURRENCY STRATEGIES

Last-in-wins updating

Match-all updating

Timestamp-based updating

Changed-value updating
8/25
DISCONNECTED DATA
DataSet is easier to use than a DataReader, if you:

need a convenient package to send the data to another
component

need a convenient file format to serialize the data to disk

want to navigate among several different tables

want to use data binding with user interface controls

want to manipulate data as XML

want to provide batch updates
9/25
THE DATASET
10
DATASET XML AND MISCELLANEOUS METHODS
11
DATAADAPTER CLASS
12/25
DATAADAPTER CLASS
13/25
FILLING A DATASET
14/25
MULTIPLE TABLES AND RELATIONSHIPS
15/25
REFERENTIAL INTEGRITY
Can’t delete a parent record if there are linked child
rows
 Can’t create a child record that references a
nonexistent parent

createConstraints = false
16/25
SEARCHING FOR SPECIFIC ROWS
Select() method allows to search rows in DataTable
using a SQL expression
17/25
DATA BINDING
1.
2.
(
)
3.
18/25
DATAVIEW CLASS
DataView is a representation of the data in a DataTable
Filtering (DataView.RowFilter property)
 Sorting (DataView.Sort property)

The default DataView – DataTable.DefaultView
property
19/25
FILTER OPERATORS
20/25
CALCULATED COLUMNS
DataColumn.Expression property
 DataTable.Columns.Add( … )

21/25
TYPED DATASETS
The information about the schema of the DataSet
is already “hard-coded” into DataSet
 Access table names and field values using
strongly typed property names

22/25
To create a typed DataSet, you need XSD (XML schema document)
WEB APPLICATIONS AND THE DATASET
Straightforward
commands
DataSet
23/25
WEB APPLICATIONS AND THE DATASET
Perform direct
updates using
straightforward
commands
Retrieve data into
the DataSet
24/25
СПАСИБО ЗА ВНИМАНИЕ!

???
25/25