Data Access with ADO.NET

Slides:



Advertisements
Similar presentations
Database Connections with ASP.Net
Advertisements

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.
1 Interface IDbConnection ConnectionString defines data base connection Open and close connection Properties of connection object Creates Command-Object.
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.
ADO. NET. What is “ADO.Net”? ADO.Net is a new object model for dealing with databases in.Net. Although some of the concepts are similar to the classical.
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.
Programming in ADO.NET: Data-Centric Applications and ADO.NET Original copyright by Microsoft, 2002, with minor modifications by Dan Eaves, 2005.
Objective In this session we will discuss about : What is ADO. NET ?
In C# program Before you can start using the ODBC class definitions, you will need to include the right module. using System.Data.Odbc; // ODBC definitions.
Data Access with ADO.NET Dr. Herbert Praehofer Institute for System Software Johannes Kepler University Linz Dr. Dietrich Birngruber Ecolog GmbH Wels ©
CIS 764 – Presentation Somil Chandwani.  With Microsoft Data Access Components (MDAC), developers can connect to and use data from a wide variety of.
ODBC, OLE DB, and ADO Introduction Dr. Ron Eaglin.
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.
Web Services Week 8 Aims: –Using web services as front ends to databases Objectives: –Review of relational databases –Connecting to and querying databases.
Accessing SQL Server and OLE DB from.NET Svetlin Nakov Telerik Corporation
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.
ADO.Net CS795. What is ADO.Net? Database language spoken by managed applications ADO.net database accesses go through modules: data providers –SQL Server.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.
1 Introduction to ADO.NET Microsoft ADO.NET 2.0 Step by Step Rebecca M Riordan Microsoft Press, 2006.
 It is the primary data access model for.Net applications  Next version of ADO  Can be divided into two parts ◦ Providers ◦ DataSets  Resides in System.Data.
Database, SQL, and ADO.NET- Part 1 Session 11 Mata kuliah: M0874 – Programming II Tahun: 2010.
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.
Module 9: Accessing Relational Data Using Microsoft Visual Studio.NET.
Module 7: Accessing Data by Using ADO.NET
ADO.NET Data Access. Page  2 SQL  When we interact with the datasource through ADO.NET we use the SQL language to retrieve,modify,update information.
© 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:
1.Net programmingADO.NETNOEA / PQC ADO.NET Architecture Connection factory Config file DataReader DataSet DataGrid Autogeneration of SQL.
Presented by Joseph J. Sarna Jr. JJS Systems, LLC
An Introduction to ADO.Net Marmagna Desai.NET Seminar, Fall-2003.
 It is the primary data access model for.Net applications  Next version of ADO  Can be divided into two parts ◦ Providers ◦ DataSets  Resides in System.Data.
1 11/10/05CS360 Windows Programming ADO.NET. 2 11/10/05CS360 Windows Programming ADO.NET  Behind every great application is a database manager o Amazon.
Why ADO.NET Not your father’s Data Access.
ADO.NET AND STORED PROCEDURES - Swetha Kulkarni. RDBMS ADO.NET Provider  SqlClient  OracleClient  OleDb  ODBC  SqlServerCE System.Data.SqlClient.
ADO.Net CS795. What is ADO.Net? Database language spoken by managed applications ADO.net database accesses go through modules: data providers –SQL Server.Net.
HNDIT Rapid Application Development
Active Data Objects Using.Net ADO.Net Farooq Ahmed Amna Umber Summayya Shehzad.
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.
Querying Information in a Database. CONTENTS Relational Database Systems Creating Database with SQL Server Reading Data with LINQ Requirements to Get.
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.
 ADO.NET is an object-oriented set of libraries that allows you to interact with data sources  Commonly, the data source is a database, but it could.
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
Accessing the Database Server: ODBC, OLE DB, and ADO
Introduction to Database Processing with ADO.NET
ADO.NET Framework.
Lecture 6 VB.Net SQL Server.
ADO.NET Accessing Databases in VS.NET
VB.NET Using Database.
Tonga Institute of Higher Education
Bài 5: ADO.NET 5.1. Khái niệm 5.2. Các lớp và không gian tên cơ bản của ADO.NET 5.3. Thao tác với dữ liệu kết nối – Connected 5.4. Thao tác với dữ liệu.
Lecture Set 14 B new Introduction to Databases - Database Processing: The Connected Model (Using DataReaders)
Database Objects 1/12/2019 See scm-intranet.
Introduction of Week 11 Return assignment 9-1 Collect assignment 10-1
Chapter 10 ADO.
Database Processing: David M. Kroenke’s Chapter Twelve: Part One
M S COLLEGE OF ART’S, COMM., SCI. & BMS Advance Web Programming
Introduction to Database Programming through ADO. NET
Presentation transcript:

Data Access with ADO.NET

ADO.NET Is the .NET technology for accessing structured data Uniform object oriented interface for different data sources relational data bases XML data other data sources Designed for distributed and Web applications Provides 2 models for data access connection-oriented connectionless Überblick

Idea of Universal Data Access Connection of (object-oriented) programming languages and relational data bases Uniform programming model and API Special implementations for data sources (providers) MsSql DB2 Oracle Application ? provider ODBC API

Data Providers Microsoft’s layered architecture for data access ADO.NET SQL Server Oracle MySQL ODBC OLEDB SQL-data Non-SQL-data MS SQL Server, Oracle, Jet, Foxpro, ... Directory Services, Mail, Text, Video, ...

History of Universal Data Access (Microsoft) ODBC OLE DB ADO (ActiveX Data Objects) ADO.NET ADO ADO.NET connection-oriented connection-oriented + connectionless sequential access sequential access + main-memory representation with direct access only one table supported more than one table supported COM-marshalling XML-marshalling Überblick

Architecture of ADO.NET connectionless connection-oriented

Connection-oriented versus Connectionless Keeps the connection to the data base alive Always up-to-date data Intended for applications with: short running transactions only a few parallel access operations Connectionless No permanent connection to the data source Data cached in main memory Changes in main memory may be in conflict with changes in data source many parallel and long lasting access operations (e.g.: Web applications)

ADO.NET Assembly and Namespaces System.Data.dll Namespaces: System.Data general types System.Data.Common classes for implementing providers System.Data.OleDb OLE DB provider System.Data.SqlClient Microsoft SQL Server provider System.Data.SqlTypes data types for SQL Server System.Data.Odbc ODBC provider (since .NET 1.1) System.Data.OracleClient Oracle provider (since .NET 1.1) System.Data.SqlServerCe Compact Framework

Architecture DbConnection DbCommand DbTransaction DataReader represents connection to data source DbCommand represents a SQL command DbTransaction represents a transaction commands can be executed within a transaction DataReader result of a data base query allows sequential reading of rows

IDbConnection: Property ConnectionString Key-value-pairs separated by semicolon (;) Configuration of the connection name of the provider identification of data source authentication of user other database-specific settings e.g.: OLEDB: "provider=SQLOLEDB; data source=127.0.0.1\\NetSDK; initial catalog=Northwind; user id=sa; password=; " "provider=Microsoft.Jet.OLEDB.4.0;data source=c:\bin\LocalAccess40.mdb;" "provider=MSDAORA; data source=ORACLE8i7; user id=OLEDB; password=OLEDB;“ e.g.: MS-SQL-Server: "data source=(local)\\NetSDK; initial catalog=Northwind; user id=sa; pooling=false; Integrated Security=SSPI; connection timout=20;" SqlServer Access Oracle Überblick

ExecuteNonQuery Method int ExecuteNonQuery(); Executes the non-query operation specified in CommandText UPDATE INSERT DELETE CREATE TABLE … Result is number of affected rows Example: cmd.CommandText = "UPDATE Empls SET City = ’Seattle’ WHERE iD=8"; int affectedRows = cmd.ExecuteNonQuery();

ExecuteScalar Method object ExecuteScalar(); Returns the value of the 1st column of the 1st row delivered by the query CommandText typically is an aggregate function Example: cmd.CommandText = " SELECT count(*) FROM Employees "; int count = (int) cmd.ExecuteScalar(); Überblick

ADO.NET and Transactions 2 transaction models local transactions: transactions for one connection provided by ADO.NET distributed transactions: transactions for several connections usage of Microsoft Distributed Transaction Component (MSDTC) namespace System.Transaction

Local Transactions with ADO.NET ADO.NET supports transactions Commands can be executed within transactions Execution of commands are committed with Commit aborted with Rollback

CONNECTIONLESS ORIENTED Motivation and Idea Many parallel, long lasting access operations Connection-oriented data access too costly Caching data in main memory  “main memory data base“ Only short connections for reading and updates  DataAdapter Main memory data base independent from data source conflicting changes are possible

Microsoft 3-Tier Architecture taken from: Introduction to Data Access with ADO.NET, http://msdn.microsoft.com/library/

ADO.NET Technology Chain Data store DataSet DataSet DataAdapter Conn ection XML DataGrid DataView

Architecture of Connectionless Data Access connection-oriented

Summary Connection-oriented data access model for applications with only a few parallel, short running transactions object-oriented interface abstracts from data source access to database by SQL commands Connectionless data access model for applications with many parallel, long running transactions DataSet as main memory data base DataAdapter is used as connector to the data source tight integration with XML well integrated in the .NET Framework (e.g.: WebForms, WinForms)