Overview of Database Access in .Net

Download Report

Transcript Overview of Database Access in .Net

Overview of Database Access in
.Net
Josh Bowen
CIS 764-FS2008
Introduction
• To best understand a technology it is often
useful to look at what came before
• Within .net three main classes are used for
database access
• A new technology called LINQ has been
introduced with the latest .Net framework
Timeline
ODBC
DAO
OLE
DB
ADO
RDO
JDBC
ADO.net
v1.0
ADO.net
v2.0
ADO.net
v3.0
LINQ
1992
1992
1995 1996
1996
1997
2002
2005
2006
2007
•This is not an exhaustive list of database access technologies
•There are as many DB access methods as there are stars
in the sky (well almost)
•Each of these technologies influenced the creation of .Net
database access technology
Low Level Access
• ODBC – Created to provide a common method
for accessing databases, implemented many
times by many different companies
• DAO,OLE DB,RDO,ADO – Created to simplify
access to databases, often used ODBC, many
tied to specific products such as Access or
Visual Basic
JDBC
• Database access in Java
• 4 Major Classes
– Driver – Specific to database type
– Connection – Information about the DB to access
– Statement – The SQL to execute
– Results – Data retrieved from database
• One option was a connection to ODBC
ADO
• The Microsoft technology which most
influenced .net
• Relied on 2 major classes
– Connection: Information about how to connect to
DB, executed queries against connection class
– Recordset: Held information retrieved from DBs
• Built upon OLE DB
• ActiveX Data Objects – Based on COM
ADO.net
• Part of the .Net framework from the beginning
• Similar to ADO, but not simply a .Net version of
ADO
• Based on three classes
– Connection: DB type specific, Holds information
necessary to communicate with DB
– Adapter: Holds the SQL commands for SELECT,
DELETE, UPDATE and ADD
– Dataset: Holds the data, Can contain multiple tables
and relations between tables
ADO.net cont.
• To make changes to data change the data in
the data set, and use the adapter to propagate
changes to database
• The dataset can be used to store information
from any type of data source, only the
connection and adapter are specific to
database type
• ADO.net can be used to query other data
sources like XML files
LINQ
• Introduced as part of the .Net framework 3.5
• Completely new way to access data
• Select statements are made from within the
language, not as strings passed to a query
class
• Can be used to query not only databases but
also collections and arrays which implement
the correct interfaces
LINQ cont.
• Language Integrated Query – The queries are
actually compiled parts of the program,
complete with intellisense
• Currently can be used with SQL server, other
database types need to be accessed using
ADO.net components along with LINQ
Conclusion
• The history of database access within
Microsoft Windows is of decreasing
complexity
• ADO and JDBC both influenced the design of
data access in .net
• ADO.net provides a simple yet robust method
of accessing data
• LINQ represents a major shift in the way
databases are accessed