An Introduction to ADO.Net Marmagna Desai.NET Seminar, Fall-2003.

Slides:



Advertisements
Similar presentations
17. Data Access ADO.Net Architecture New Features of ADO.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.
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.
.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 ?
ADO.NET – part II August 2004 [ Marmagna Desai]. CONTENTS ADO vs ADO.NET ADO.NET – Managed providers Connecting to Database SqlConnection Selecting Database.
Programming with Visual Basic.NET An Object-Oriented Approach  Chapter 8 Introduction to Database Processing.
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.
Developing Web Applications Using Microsoft ® Visual Studio ® 2008.
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.
Chapter 3 Introduction to ADO.NET 3.1 The ADO and ADO.NET ActiveX Data Object (ADO) is developed based on Object Linking and Embedding (OLE) and Component.
Moving from Microsoft ® ADO 2.X To ADO.NET Jackie Goldstein Renaissance Computer Systems Ltd. MSDN Regional Director, Israel Prerequisites.
Database, SQL, and ADO.NET- Part 1 Session 11 Mata kuliah: M0874 – Programming II Tahun: 2010.
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.
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
© 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
Module 3: Performing Connected Database Operations.
 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 Data Classes- DataView DataGridView Control. Objectives 2  Data Class  DataAdapter  DataReader  DataSet  DataTable  DataView  DataGridView Control.
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.
Mauricio Featherman, Ph.D. Washington St. University
Why ADO.NET Not your father’s Data Access.
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
ADO.NET FUNDAMENTALS BEGINNING ASP.NET 3.5 IN C#.
Module 4 Introduction ADO.NET.
C# .NET Software Development
Active Data Objects Using.Net ADO.Net Farooq Ahmed Amna Umber Summayya Shehzad.
Module 5 Data Classes DataView – DataGridView Control 1.
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.
Querying Information in a Database. CONTENTS Relational Database Systems Creating Database with SQL Server Reading Data with LINQ Requirements to Get.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 The SqlCommand Object ADO.NET - Lesson 03  Training time: 15 minutes  Author:
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
 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.
ASP.NET Programming with C# and SQL Server First Edition
Data Access with ADO.NET
Introduction to ADO.NET
Introduction to Database Processing with ADO.NET
Introduction to Database Processing with ADO.NET
ADO.NET Framework.
An Introduction to ADO.Net
Active Data Objects Binding ASP.NET Controls to Data
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.
برنامه نویسی سیستم های شی گرا
Chapter 10 ADO.
PROG Advanced Web Apps 4/13/2019 Programming Data Pages Wendi Jollymore, ACES.
Active Data Objects Binding ASP.NET Controls to Data
M S COLLEGE OF ART’S, COMM., SCI. & BMS Advance Web Programming
Introduction to Database Programming through ADO. NET
Presentation transcript:

An Introduction to ADO.Net Marmagna Desai.NET Seminar, Fall-2003

Contents What is ADO.Net? What happened to ADO? The ADO.Net object structure Connecting Commanding Readers and DataSets

What is ADO.Net? The data access classes for the.Net framework Designed for highly efficient data access Support for XML and disconnected record sets

And the.Net framework? A standard cross language interface Encapsulation of services, classes and data types Uses XML for data representation

Where does ADO sit? Visual Studio.NETVBC#C++Jscript … Common Language Specification ASP.NetWindows Forms ADO.NetXML.Net Base Class Library Common Language Runtime (CLR) WindowsCOM+ Services

What happened to ADO? ADO still exists. ADO is tightly coupled to client server architectures Needs COM marshalling to pass data between tiers Connections and locks are typically persisted

ADO / ADO.Net Comparisons FeatureADOADO.Net In memory data storage Recordset object Mimics single table Dataset object Contains DataTables Data ReadsSequentialSequential or non- sequential Data Sources OLE/DB via the Connection object Managed provider calls the SQL APIs

ADO / ADO.Net Comparisons FeatureADOADO.Net Disconnected data Limited support, suitable for R/O Strong support, with updating Passing datasets COM marshallingDataSet support for XML passing ScalabilityLimitedDisconnected access provides scalability

Client SQL.NET Data Provider OLE DB.NET Data Provider ODBC.NET Data Provider OLE DB Provider ODBC Driver SQL SERVER Other DB.NET Data Providers

Rows DataSet.Net Data Provider Client Connection Command database DataAdapter DataReader Data Provider Functionality

ADO.Net object model DataAdapter Command DataSet Errors Collection Connection Parameters Data Source Fill Update SelectCommandInsertCommand UpdateCommand DeleteCommand

Namespaces System.Data & System.Data.Common System.Data.SqlClient & System.Data.OleDB System.Data.SqlTypes System.XML & System.XML.Schema

Using Namespaces VB.Net Imports System.Data Imports System.Data.SqlClient Dim sqlAdp as SqlDataAdapter C# using System.Data; using System.Data.SqlClient; SqlDataAdapter sqlAdp= new SqlDataAdapter();

SQL Namespace Objects using System.Data.SqlClient; SqlConnectionSqlConnection SqlCommandSqlCommand SqlDataReaderSqlDataReader SqlDataAdapterSqlDataAdapter SqlParameter SqlParameterCollection SqlError SqlErrorCollection SqlException SqlTransaction SqlDbType

Connecting to SQL using System.Data.SqlClient; string sConnectionString = "Initial Catalog=Northwind; Data Source=localhost; Integrated Security=SSPI;"; SqlDataAdapter sqlAdp= new SqlDataAdapter(sConnectionString); sqlAdp.Close(); sqlAdp.Dispose();

Connection Pooling ADO.Net pools connections. When you close a connection it is released back into a pool. SqlConnection conn = new SqlConnection(); conn.ConnectionString = "Integrated Security=SSPI;Initial Catalog=northwind"; conn.Open(); // Pool A is created. SqlConnection conn = new SqlConnection(); conn.ConnectionString = "Integrated Security=SSPI;Initial Catalog=pubs"; conn.Open(); // Pool B is created because the connection strings differ. SqlConnection conn = new SqlConnection(); conn.ConnectionString = "Integrated Security=SSPI;Initial Catalog=northwind"; conn.Open(); // The connection string matches pool A.

Getting data SqlCommand ExecuteReader ExecuteNonQuery ExecuteScalar ExecuteXMLReader SqlDataAdapter DataSet

Using the command object SqlCommand Multiple constructors New() New(cmdText) New(cmdText, connection) New(cmdText, connection, transaction)

Using the command object string sSelectQuery = "SELECT * FROM Categories ORDER BY CategoryID"; string sConnectionString = "Initial Catalog=Northwind; Data Source=localhost; Integrated Security=SSPI;"; SqlConnection objConnect = new SqlConnection(sConnectString); SqlCommand objCommand = new SqlCommand(sSelectQuery, objConnect); /* objCommand.CommandTimeout = 15; objCommand.CommandType = CommandType.Text; */ objConnect.Open(); SqlDataReader drResults; drResults = objCommand.ExecuteReader() drResults.Close(); objConnect.Dispose();

Command Methods.ExecuteReader() - Returns DataReader.ExecuteNonQuery() - Returns # of Rows Affected.ExecuteXMLReader() - Returns XMLReader Object to Read XML documentation.ExecuteScaler() - Returns a Single Value e.g. SQL SUM function.

The DataReader object DataReader objects are highly optimised for fast, forward only enumeration of data from a data command A DataReader is not disconnected

The DataReader object Access to data is on a per record basis. Forward only Read only Does support multiple recordsets

Creating a data reader SqlDataReader sqlReader; sqlReader = sqlCommand.ExecuteReader(); while (sqlReader.Read()) { // process, sqlReader("field") } sqlReader.Dispose();

Other Methods GetString(), GetInt() etc. GetSqlString(), GetSqlInt32() etc. GetValues() IsDBNull() GetSchemaTable()

DataSets In-memory representation of data contained in a database/XML Operations are performed on the DataSet, not the data source Can be created programmatically, using a DataAdapter or XML schema and document (or any mixture)

Creating DataSets Setup SqlConnection Setup a SqlDataAdapter Create a DataSet Call the.Fill() method on the DA

DataAdapters Pipeline between DataSets and data sources Geared towards functionality rather than speed Disconnected by design Supports select, insert, delete, update commands and methods

DataAdapters Must always specify a select command All other commands can be generated or specified

Using the DataAdapter SQLDataAdapter sqlDA = new SqlDataAdapter(); sqlDA.SelectCommand = new SqlCommand ("select * from authors“, sqlConnection); DataSet sqlDS = new DataSet("authorsTable"); sqlDA.Fill(sqlDS, "authorsTable");

DataAdapters For speed and efficiency you should set your own InsertCommand, UpdateCommand and DeleteCommand Call GetChanges to seperates the updates, adds and deletes since the last sync. Then sync each type.

DataTables A DataSet contains one or more DataTables. Fields are held within the DataTable. And in DataRows, DataColumns.

Sets, Tables and Rows DataSet DataTable DataRow

Using DataTables With a DataTable we can Insert, modify and update Search Apply views Compare Clear Clone and Copy

DataRelations New to ADO.Net Tables within a DataSet can now have relationships, with integrity. Supports cascading updates and deletes.

DataViews Like a SQL view Single, or multiple tables Normally used with GUI applications via Data Binding.

References ADO.Net Programmer’s Reference Bilbija, Dickenson et al. Wrox Press My

Thank You!! -Marmagna Desai