Overview of ADO.NET with the.NET Framework Scalable Development, Inc. Building systems today that perform tomorrow.

Slides:



Advertisements
Similar presentations
17. Data Access ADO.Net Architecture New Features of ADO.NET
Advertisements

Database Connections with ASP.Net
ADO.NET: Working in Disconnected Environment Sergey Baidachni MCT, MCSD, MCDBA.
ADO vs ADO.NET ADOADO.NET Client/server coupledDisconnected collection of data from data server Uses RECORDSET object (contains one table) Uses DATASET.
Chapter 10 ADO. What is ADO? ADO is a Microsoft technology ADO stands for ActiveX Data Objects ADO is a programming interface to access data in a database.
Introduction to Database Processing with ADO.NET.
1 ADO.NET. 2.NET Framework Data Namespaces System.Data –Base set of classes and interfaces for ADO.NET System.Data.Common –Classes shared by the.NET Data.
14 1 Chapter 14 Database Connectivity and Web Development Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel.
.NET Mobile Application Development Data in Distributed Systems Accessing Data with.NET.
ASP.NET Programming with C# and SQL Server First Edition Chapter 8 Manipulating SQL Server Databases with ASP.NET.
Chapter 12 Database Connectivity with ASP.NET JavaScript, Third Edition.
Objective In this session we will discuss about : What is ADO. NET ?
Overview of Database Access in.Net Josh Bowen CIS 764-FS2008.
CIS 764 – Presentation Somil Chandwani.  With Microsoft Data Access Components (MDAC), developers can connect to and use data from a wide variety of.
Chapter 8 Binding Data to Web Controls. ASP.NET 2.0, Third Edition2.
Overview of ADO.NET Whidbey  Wallace B. McClure  Scalable Development, Inc. Scalable Development, Inc. Building systems today that perform tomorrow.
ADO.NET – part II August 2004 [ Marmagna Desai]. CONTENTS ADO vs ADO.NET ADO.NET – Managed providers Connecting to Database SqlConnection Selecting Database.
Introduction to ADO.Net and Visual Studio Database Tools ISYS 512.
ODBC, OLE DB, and ADO Introduction Dr. Ron Eaglin.
Visual Studio ®.NET Data with XML Carlotta Eaton ( Associate Professor of IST New River Community College Slides by Microsoft Modified.
 Wallace B. McClure  Scalable Development, Inc. Scalable Development, Inc. Building systems today that perform tomorrow. Designing & Building Windows.
ADO.NET A2 Teacher Up skilling LECTURE 3. What’s to come today? ADO.NET What is ADO.NET? ADO.NET Objects SqlConnection SqlCommand SqlDataReader DataSet.
Overview of Data Access MacDonald Ch. 15 MIS 324 Professor Sandvig.
CIS 451: Using ASP.NET Objects with SQL Dr. Ralph D. Westfall February, 2009.
Developing Web Applications Using Microsoft ® Visual Studio ® 2008.
A Simple Introduction. What is ADO.net? First the word ADO stands for ActiveX Data Objects And it is an integral part of.Net Framework of Microsoft hence.
Needs for Accessing Database To make your web site more dynamic and maintainable, you can display information on your web pages that are retrieved from.
Databases and Data Access  Introduction to ADO.NET  ADO.NET objects  ADP.NET namespaces  Differences between ADO and ADO.NET.
.NET Data Access and Manipulation ADO.NET. Overview What is ADO.NET? Disconnected vs. connected data access models ADO.NET Architecture ADO.NET Core Objects.
Moving from Microsoft ® ADO 2.X To ADO.NET Jackie Goldstein Renaissance Computer Systems Ltd. MSDN Regional Director, Israel Prerequisites.
Copyright ©2004 Virtusa Corporation | CONFIDENTIAL ADO.Net Basics Ruwan Wijesinghe Trainer.
Objectives In this lesson, you will learn to: *Identify the need for ADO.NET *Identify the features of ADO.NET *Identify the components of the ADO.NET.
10/26/20151 Chapter 3 Introduction to ADO.NET In this chapter, you will: Learn the basic classes in ADO.NET and its architecture Learn the different ADO.NET.
ASP.NET Rina Zviel-Girshin Lecture 5
Module 9: Accessing Relational Data Using Microsoft Visual Studio.NET.
Session 8: ADO.NET. Overview Overview of ADO.NET What is ADO.NET? Using Namespaces The ADO.NET Object Model What is a DataSet? Accessing Data with ADO.NET.
Module 7: Accessing Data by Using ADO.NET
What is database?  Any Method for access info into Application from DataBase?  ODBC is standard for Accessing Data.  Problem with ODBC:  Information.
Christopher M. Pascucci.NET Programming: Databases & ADO.NET.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 Introduction to ADO.NET ADO.NET - Lesson 01  Training time: 10 minutes  Author:
Presented by Joseph J. Sarna Jr. JJS Systems, LLC
An Introduction to ADO.Net Marmagna Desai.NET Seminar, Fall-2003.
Why ADO.NET Not your father’s Data Access.
DEV383 The ADO.NET DataSet and You Jackie Goldstein General Manager Renaissance Computer Systems
Accessing Data with Microsoft Visual C# Applications.
Why ADO.NET Not your father’s Data Access.
HNDIT Rapid Application Development
Module 4 Introduction ADO.NET.
Active Data Objects Using.Net ADO.Net Farooq Ahmed Amna Umber Summayya Shehzad.
DAT200 Microsoft® ADO.NET for ADO Classic Developers: Introducing ADO.NET Jackie Goldstein Renaissance Computer Systems
Module 2: Using ADO.NET to Access Data. Overview ADO.NET Architecture Creating an Application That Uses ADO.NET to Access Data Changing Database Records.
Data Access. ADO.NET ADO.NET is the primary library for building database solutions within the.NET Framework. ADO.NET does not replace ADO. ADO and OLEDB.
ADO .NET from. ADO .NET from “ADO .Net” Evolution/History of ADO.NET MICROSOFT .NET “ADO .Net” Evolution/History of ADO.NET History: Most applications.
.NET Data Access and Manipulation
C# 1 CSC 298 ADO.NET. C# 2 ADO.NET  A data access technology that maps very well to the world of the web (disconnected architecture)  data is retrieved.
DAT 390 Advanced ADO.NET Programming Techniques Jackie Goldstein Renaissance Computer Systems
Integrating Data Lesson 6.
ASP.NET Programming with C# and SQL Server First Edition
Introduction to ADO.NET
Introduction to Database Processing with ADO.NET
Introduction to Database Processing with ADO.NET
ADO.NET Framework.
Lecture 6 VB.Net SQL Server.
Chris Menegay Sr. Consultant TECHSYS Business Solutions
Active Data Objects Binding ASP.NET Controls to Data
ADO.NET Accessing Databases in VS.NET
Tonga Institute of Higher Education
Database Objects 1/12/2019 See scm-intranet.
Chapter 10 ADO.
Active Data Objects Binding ASP.NET Controls to Data
Presentation transcript:

Overview of ADO.NET with the.NET Framework Scalable Development, Inc. Building systems today that perform tomorrow.

.NET Experiences  PDC 2000 Build (July 2000).  Visual Studio 1.0 Beta 1 (November 2000).  Book began (January 2001).  Visual Studio 1.0 Beta 2 (June 2001).  First Production ASP.NET App (July 2001).  Production Windows Service (November 2001). Runs today.  4 Production Applications by shipment.  Multiple running applications.

.NET Resources  ASP.NET –  AspAdvice –  Windows Forms –  Architecture – msdn.microsoft.com/architecture .NET News –

Agenda  Design Philosophy  Architectural Overview  Features  When to use What (Code Examples)  Summary

Design Philosophy  Unified Data Story (data, xml, cache objects)  Data is Data; object model is choice  XML objects feel like XML, Data objects feel like Data, Typed Objects feel like objects  Factored components  Explicit model; no black boxes! (Customers/helper code wires together components)  Predictable behaviour, semantics  Optimized performance  Disconnected Relational DataSet  Get Data as fast as possible

Managed Data Overview

What Happened to My RecordSet?  RecordSet  Updateable? Scrollable? Bookmarks? Rowcount? Holding server resources? Cache on client?  DataReader  Connected, non-cached, FO/RO RecordSet  DataSet  Disconnected, cached, scrollable data  DataAdapter  Logic for populating the DataSet and propagating changes back to the datasource

Managed Providers  Manages interaction to a data source  Managed equivalent of OLE DB layer  Directly exposes consumer interfaces  Not a full featured data store interface  Specific to (Optimized for) DataSource  Managed Provider Object Model  Connection  Like ADODB.Connection  Command  Like ADODB.Command  DataReader  Similar to FO/RO ADODB.RecordSet  Fields accessed through strongly typed, indexed accessors

Database Support  System.Data.SQLClient  SQL Server 7  SQL Server 2000  Oracle.DataAccess (ODP.NET).  System.Data.Oracle (MS).  DB2 (only supports.NET 1.0).  MySql.  System.Data.OleDb  System.Data.Odbc ODBC drivers.

Oracle Managed Providers  Microsoft. No support for COM+.  Oracle. Requires Oracle 9iR2 client.

Oracle Support Through OleDb  Microsoft Driver for Oracle. (MsDaOra)  7.x datatypes.  No 8.x datatypes.  Oracle OleDb Driver. (OraOleDb.Oracle)  7.x datatypes.  8.x datatypes.  9.x datatypes.  COM+ challenged.

Oracle Support Through ODBC  Microsoft Driver for Oracle.  Oracle ODBC driver.  Thread challenged.

Oracle Gotchas  Use the latest Oracle SQL Net.  Don’t use COM+ transactions, unless you need them. Info - Oracle is working on an OleDb driver that supports COM+ transactions better.  Always close connections!!!!!!

DataSet Common client data store  Relational View of Data  Tables, Columns, Rows, Constraints, Relations  Directly create metadata and insert data DataSet Tables Table Columns Column Constraints Constraint Rows Row Relations Relation

DataSet Common client data store  Explicit Disconnected Model  Disconnected, remotable object  No knowledge of data source or properties  Common Behaviour  Predictable performance characteristics  Strong Typing  3-D Collection  What to return from a DAL.  Uses DataReader underneath the covers.  Some column metadata is not available.

Data Adapter  Loads a table from a data store and writes changes back.  Exposes two important methods:  Fill(DataSet,DataTable)  Update(DataSet,DataTable)  Provides mappings between tables & columns  User provides insert/update/delete commands  Allows use of Stored Procedures  CommandBuilder component available (not used much in ASP.NET)  Allows single DataSet to be populated from multiple different datasources

ADO.NET and XML  The DataSet  Loads/saves XML data into/out of DataSet  Schema can be loaded/saved as XSD  Schema can be inferred from XML Data  The DataSet can be associated with an XmlDataDocument  Exposes a relational view over structured XML  According to the DataSet schema  Allows strong typing, control binding, relational access of XML data  Allows XML tools (schema validation, XSL/T, XPath queries) against relational data  Preserves full fidelity of XML Document

When to use What  Connected Data Access  Code Examples:  Retrieving Results  Insert, Update, and Delete.  Disconnected Data Access  Code Examples:  Application Data  Loading XML  Client Cursor Updating  XML View of Relational Data  Code Example:  SQLXML  XML Manipulations

Connected Data Access  Connected Data Access - Managed Providers  Connection, Transaction  Connecting to DataSource  Starting/Ending Transactions  Command, Parameters  Database Updates, Selects, DDL  DataReader  (FO/RO) Server Cursor  DataAdapter  Pushing data into Dataset  Reading changes out of DataSet

Code: Retrieving Results ‘Create and open an OleDbConnection Dim OleDbCn as new OleDbConnection(“……”) OleDbCn.Open() ‘Create and execute OleDbCommand Dim OleDbCmd as new OleDbCommand("Select * from authors where...", OleDbCn) Dim dr as DataReader dr = OleDbCmd.ExecuteReader() ‘Retrieve Results while(dr.Read()) Console.WriteLine("Name = " + dr("au_lname“)) End while dr.Close() OleDbCn.Close() ‘This is VERY IMPORTANT

Disconnected Data Access  Disconnected Data Access - DataSet  Application Data  Remoting Results  SOAP, WebMethods, Remoting  Caching Results  ASP.NET Cache  Persisting results  Save Data as XML, Schema as XSD  User interaction  Scrolling, sorting, filtering  DataView, DataViewManager  Binding Windows controls

Code: Application Data ‘ Create an "Inventory" Table Dim ds as new DataSet() Dim inventory as new DataTable("Inventory") inventory.Columns.Add("TitleID",typeof(Int32)) inventory.Columns.Add("Quantity",typeof(Int32)) ds.Tables.Add(inventory) ‘ Add a record to the Inventory table Dim row as inventory.NewRow() Row("TitleID“)=1 Row("Quantity“)=25 inventory.Rows.Add(row)

Code: Loading XML ‘Load DataSet with XML Dim ds as new DataSet() ds.ReadXml("inventory.xml") ‘Add a record to the Inventory table Dim inventory as new DataTable = ds.Tables("Inventory“) Dim row as DataRow = inventory.NewRow() Row("TitleID“)=1 Row("Quantity“)=25 inventory.Rows.Add(row) ‘Write out XML ds.WriteXml("updatedinventory.xml")

Code: Insert/Update/Delete Dim OleDbCn as new OleDbConnection(“…….”) Dim OleDbCM as new OleDbCommand( “Insert/Update/Delete Command“, OleDbCn) OleDbCn.Open() OleDbCm.ExecuteNonQuery() If OleDbCn.State <> ConnectionState.StateClosed then OleDbCn.Close() End if OleDbCn = Nothing ‘Old habits die hard

Code: Client Cursor Updating (easy) ‘Populate DataSet Dim OleDbDA as new OleDbDataAdapter( "Select * from customers“, OleDbCn); Dim ds as new Dataset() OleDbDA.MissingSchemaAction = MissingSchemaAction.AddWithKey OleDbDA.Fill(ds, "Customer") ‘Find customer w/PK value of 256 Dim dr as DataRow = ds.Tables("Customer“).Rows.Find(256) ‘Change LastName Dr("LastName“) = "Smith" ‘Update DataBase Dim OleDbCb as new OleDbCommandBuilder = OleDbCommandBuilder(da) OleDbDa.Update(ds, "Customer")

Code: Client Cursor Operations (harder) ‘Populate DataSet Dim OleDbDA as new OleDbDataAdapter( "Select customerId, customerName from customers“, OleDbCn); Dim ds as new Dataset() Dim dr as DataRow OleDbDA.Fill(ds, "Customer") OleDbDA.InsertCommand = new OleDbCommand(“insert into customers (CustomerName) values OleDbCn) dr = ds.Tables(“Customer”).NewRow() ‘Add Customer Name Dr("Customer Name“) = "Fred's Company" ‘Update DataBase ds.Tables(“Customer”).Rows.Add(dr) OleDbDA.Update(ds, “Customer”)

Notes on the Client Cursor Update  Individual commands are sent.  Can be wrapped in a transaction.  CommandBuilder is “relatively” inefficient.

Code: Manual Transaction Dim OleDbCM as new OleDbCommand( “Insert/Update/Delete Command“, OleDbCn) Dim OleDbTx as OleDbTransaction OleDbTx = OleDbCn.BeginTransaction(Isolation.ReadUncommitted) OleDbCm.Transaction = OleDbTx Try OleDbCn.Open() OleDbCm.ExecuteNonQuery() OleDbTx.Commit() Catch exc as Exception OleDbTx.RollBack() Throw( new Exception( “Error Occurred”, exc.InnerException ) Finally If OleDbCn.State <> ConnectionState.StateClosed then OleDbCn.Close() End if End Try OleDbCn = Nothing

Cleanup  Close your connection objects and return them to the connection pool.  Dispose all objects. Don't wait on the finalizer.

Great, Now What’s Missing?  Server-side scrollable cursor support. (not an issue for Oracle)  Complete column information.  ADOX.Catalog type of support. No support for creating tables, columns, users, indexes, ……..

ADO Classic in.NET  Works.  Can continue to use it.  Required for ADOX support.

Summary  ADO.NET is…  Optimized for Data Access.  Managed Providers for connected access  DataSet for disconnected, user interaction  DataReader for connected RO use.  Open Architecture  No Black Boxes  Tightly Integrated with XML  DataSet reads/writes XML  XmlDataDocument integrates relational and XML views

Questions?  Scalable Development, Inc.  Consulting & Development Services.    END Scalable Development, Inc. Building systems today that perform tomorrow.