260 likes | 593 Views
ODBC, OLE DB, and ADO Introduction. Dr. Ron Eaglin. 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.
E N D
ODBC, OLE DB, and ADOIntroduction Dr. Ron Eaglin
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 OLE DBProviders OLE DBConsumer ODBC Data Sources OLEDB Client Application Code MSDASQL.DLL ADO SQL Server Db Client Application that uses OLE DB SQLOLEDB.DLL MDB Files MSJTOR35.DLL
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 .CommonContains classes shared by both System.Data .OleDb .SqlClient SqlCommandSqlConnectionSqlDataReaderSqlDataAdapter OleDbCommandOleDbConnectionOleDbDataReaderOleDbDataAdapter
System.Data Classes System.Data DataSet - In-memory cache of data DataTable - In-memory cache of a database table DataRow - Used to manipulate a row in a DataTable DataColumn - Used to define the columns in a DataTable DataRelation - Used to relate 2 DataTables to each other DataViewManager - Used to create views on DataSets
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();