Upload
phoebe-tucker
View
218
Download
1
Embed Size (px)
Citation preview
Data Access Standards
• The reasons for ODBC, OLE DB, and ADO are to provide a standardized method and API for accessing and manipulating Data from different databases.
• ODBC (Open Database Connectivity) – is the most basic and common standard interface for accessing databases.
ODBC Conformance Levels
• Application Programming Interface– Core– Level 1– Level 2
• SQL Grammar– Minimum– Core– Extended
Establishing an ODBC Datasource
• In Control Panel, Administrative Options, there is an icon for ODBC Datasources
ODBC Datasources
• File Data Source – A physical file which can be shared among users on a single computer.
• System Data Source – A source of data that is local to a single computer. Can be remotely accessed through the computer.
• User Data Source – Available only to the user who created it.
Microsoft OLE DB
• Creates an Object Oriented Programming model on top of ODB (and other drivers) to allow a programmatic access to database through a Object Oriented interface.
Using Microsoft OLE DB
Client Application
Code
ODBC Data
Sources
MDB Files
SQL Server
ADO
OLE DBConsumer
OLEDB
MSDASQL.DLL
SQLOLEDB.DLL
MSJTOR35.DLL
OLE DBProviders
Db Client Application
that uses OLE DB
ADO and ADO.Net
• One level of abstraction higher that OLE DB.
• Basic object model that overlies the more complex OLE DB model.
Basic Definition
• Namespace – In programming a namespace encapsulates other name spaces, programming classes, and other functions that are common and uniquely named.
ADO.Net Namespaces
• The ADO.NET Object Model– Objects of System.Data– .NET data providers
• ADO.NET namespace hierarchy– Organizes the object model– Includes:
• System.Data • System.Data.OleDb• System.Data.Common• System.Data.SqlClient• System.Data.SqlTypes
The System.Data Namespace
System.Data
.OleDb.SqlClient
OleDbCommandOleDbConnectionOleDbDataReaderOleDbDataAdapter
SqlCommandSqlConnectionSqlDataReader
SqlDataAdapter
.Common Contains classes shared by both
System.Data Classes
System.Data
DataTable - In-memory cache of a database table
DataRow - Used to manipulate a row in a DataTable
DataRelation - Used to relate 2 DataTables to each other
DataColumn - Used to define the columns in a DataTable
DataViewManager - Used to create views on DataSets
DataSet - In-memory cache of data
Using ADO.Net Classes
• Connection Object– ODBCConnection– OleDBConnection– SQLConnection
• ConnectionString property – defines the information to allow connecting to a database.
Connection Class
// create a connection string
String conStr="Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=NWIND_RW.MDB";
// create a connection object using the connection string
OleDbConnection aConn = new OleDbConnection(conStr);
// open the connection
aConn.Open();
// Perform database actions
aConn.Close();