Title: ATKA1D 'NETohjelmointi ADO'NET
1ATKA1D .NET-ohjelmointi ADO.NET
2ADO.NET dokumentaatio
3ADO.NET Data Providers
Source Understanding .NET David Chappell
Managed Code
System.Data.SqlClient
SQL .NET Data Provider
SQL Server
System.Data.OleDb
Client
OLE DB .NET Data Provider
OLE DB Provider
Other DBMS
System.Data.Odbc
ODBC Driver
Other DBMS
ODBC .NET Data Provider
CLR
Notes by Helia / Martti Laiho, Tuomo Ketomäki,
2002
4System.Data.OleDb
5System.Data.Odbc
6ADO.NET Data Provider
Source Understanding .NET David Chappell
.NET Data Provider
Client
Connection
Parameters
Command
Rows
DataReader
DBMS
DataAdapter
DataSet
- SQL .NET Provider (for SQL Server)
- OLE DB .NET Provider
- ODBC .NET Provider
Notes by Helia / Martti Laiho, Tuomo Ketomäki,
2002
7ADO.NET Data Provider Objects
Source Understanding .NET David Chappell
Generic objects with interfaces, versions
depending on the Data Provider
.NET Data Provider
Client
.ConnectionString .Open .Close
Transaction
.Commit .Rollback
Connection
.BeginTransaction
Parameters
.CreateCommand
.ExecuteNonQuery
Command
Object
.ExecuteScalar
.ExecuteReader
.CommandText
DBMS
Rows
DataReader
IDataReader
.Read .Getlttypegt
DataSet
DataAdapter
- Data Providers implement object classes of their
own - SQL .NET Provider Sqlltobjectgt
- OLE DB .NET Provider OleDbltobjectgt
- ODBC .NET Provider Odbcltobjectgt
Notes by Helia / Martti Laiho, Tuomo Ketomäki,
2002-2003
8System.Data.SqlClient SqlConnection
9SqlCommand
10parameters
11SqlParameter
12SqlTransaction
13SqlDataReader
14SqlError
15SqlException
16Accessing Data with DataSets
Source Understanding .NET David Chappell
1) .Fill(DataSet, TableX)
SQL Server
SQL .NET Data Provider
3) Return DataTable
SqlDataAdapter
DataSet
SelectCommand
DataRelation
2) Execute query
Table X
Table Y
OLE DB .NET Data Provider
Oracle
OleDbDataAdapter
6) Return DataTable
SelectCommand
5) Execute query
4) Fill(DataSet, TableY)
Notes by Helia / Martti Laiho, Tuomo Ketomäki,
2002-2003
17.. Updating Database with DataSet
Source Understanding .NET David Chappell
1) .Update(DataSet)
.NET Data Provider
CommandBuilder
DataAdapter
2) Execute commands
DataSet
InsertCommand
DBMS
Table X
UpdateCommand
DeleteCommand
A DataSet cannot itself maintain an open
connection to any underlying database
Notes by Helia / Martti Laiho, Tuomo Ketomäki,
2002
18System.Data.Common
19SqlDataAdapter
20SqlCommandBuilder
21System.Data DataSet
22.. DataSet
23Using DataSets with XML-Defined Data
Source Understanding .NET David Chappell
XML string
Employees.XML
.GetXml
.ReadXml
ltemployeesgt ltemployeegt
ltnamegtBoblt/namegt ltagegt36lt/agegt
lt/employeegt ltemployeegt
ltnamegtCaseylt/namegt lt/employeegt
lt/employeesgt
DataSet
Serializing
Employee Name Age
.WriteXml
Bob 36 Casey Null
.ReadXmlSchema
Employees.XSD
.WriteXmlSchema
Notes by Helia / Martti Laiho, Tuomo Ketomäki,
2002-2003
24Synchronizing with XmlDataDocument
Source Understanding .NET David Chappell
Relational view
DataSet
Hierarchical view
XmlDataDocument
Table X
Table Y
Notes by Helia / Martti Laiho, Tuomo Ketomäki,
2002-2003
25XmlDocument
26ADO.NET DataSet Object Model
FCS Partners
DataSet
.Select
Tables
DataTable
Columns
Relations
DataColumn
Rows
DataRelation
DataRow
Constraints
Constraint
ExtendedProperties
ParentRelations
DataRelation
ChildRelations
DataRelation
Notes by Helia / Martti Laiho, Tuomo Ketomäki,
2002