Introduction to Database Programming through ADO. NET

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.
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 ?
C# programming with database Basic guideline. First step Install SQL Server 2008/2010 (Professional edition if possible) Install Visual Studio 2008/2010.
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
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.
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 2: Using ADO.NET to Access Data. Overview ADO.NET Architecture Creating an Application That Uses ADO.NET to Access Data Changing Database Records.
© 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.
Integrating Data Lesson 6.
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
Programming the Web Using ASP.Net
Lecture 6 VB.Net SQL Server.
Active Data Objects Binding ASP.NET Controls to Data
VB.NET Using Database.
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.
برنامه نویسی سیستم های شی گرا
Опит в използването на ODP.NET с Oracle 9i
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
C# Programming Unit -4 © Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Uttam Singh, Asst. Professor U4.‹N r.›
Presentation transcript:

Introduction to Database Programming through ADO. NET By Prakash G Asnani Assistant Professor Computer Science Government Science College Chikhli

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 A standard cross language interface Encapsulation of services, classes and data types Uses XML for data representation

ADO. NET in Visual Studion .NET Framework Visual Studio .NET VB C# C++ Jscript … Common Language Specification ASP.Net Windows Forms ADO.Net XML.Net Base Class Library Common Language Runtime (CLR) Windows

About ADO and its comparison with ADO .NET 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 Feature ADO ADO.Net In memory data storage Recordset object Mimics single table Dataset object Contains DataTables Data Reads Sequential Sequential or non-sequential Data Sources OLE/DB via the Connection object Managed provider calls the SQL APIs

Feature ADO ADO.Net Disconnected data Limited support, suitable for R/O Strong support, with updating Passing datasets COM marshalling DataSet support for XML passing Scalability Limited Disconnected access provides scalability

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

ADO.Net object model

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; SqlConnection SqlCommand SqlDataReader SqlDataAdapter 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();

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 Must always specify a select command Pipeline between DataSets and data sources Geared towards functionality rather than speed Disconnected by design Supports select, insert, delete, update commands and methods 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.

References ADO.Net Programmer’s Reference Bilbija, Dickenson et al. Wrox Press http://oberon.idunno.org/sql/ My email : desai8@uwindsor.ca An Introduction to ADO.Net by Marmagna Desai

Thank You