Active Data Objects Using.Net ADO.Net Farooq Ahmed Amna Umber Summayya Shehzad.

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.
Chapter 12 Database Connectivity with ASP.NET JavaScript, Third Edition.
Programming in ADO.NET: Data-Centric Applications and ADO.NET Original copyright by Microsoft, 2002, with minor modifications by Dan Eaves, 2005.
Overview of ADO.NET Chapter 1 ADO.NET 4.0 Development.
Overview of Database Access in.Net Josh Bowen CIS 764-FS2008.
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.
ODBC, OLE DB, and ADO Introduction Dr. Ron Eaglin.
Chapter 61 Managing Data Sources Introduction to ASP.NET By Kathleen Kalata.
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.
1 ASP.NET ASP.NET Rina Zviel-Girshin Lecture 4. 2 Overview Data Binding Data Providers Data Connection Data Manipulations.
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.
Lecture Set 14 B new Introduction to Databases - Database Processing: The Connected Model (Using DataReaders)
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.
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.
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
Lecture Set 14 B new Introduction to Databases - Database Processing: The Connected Model (Using DataReaders)
An Introduction to ADO.Net Marmagna Desai.NET Seminar, Fall-2003.
Module 3: Performing Connected Database Operations.
ADO.NET connections1 Connecting to SQL Server and Oracle.
 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.
Why ADO.NET Not your father’s Data Access.
HNDIT Rapid Application Development
ADO.NET FUNDAMENTALS BEGINNING ASP.NET 3.5 IN C#.
Module 4 Introduction ADO.NET.
C# .NET Software Development
© 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
Introduction to ASP.NET, Second Edition2 Chapter Objectives.
 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 Database Processing with ADO.NET
Introduction to Database Processing with ADO.NET
ADO.NET and Stored Procedures
ADO.NET Framework.
Lecture 6 VB.Net SQL Server.
Active Data Objects Binding ASP.NET Controls to Data
ADO.NET Accessing Databases in VS.NET
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)
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:

Active Data Objects Using.Net ADO.Net Farooq Ahmed Amna Umber Summayya Shehzad

Agenda ADO.Net Overveiw –Name-spaces –Shared Classess –Database Specific classess Database Connectivity –Efficient Connectivity –Methods Commands Data Reader

OverView

Why ADO.NET? ADO works great, but –Requires Windows ® –Recordsets don’t travel well across the Internet –Connected behavior is hard to work with ADO.NET solves these problems –Uses XML under the covers for all data transport –XML has no runtime/transport requirements  No special code required to marshal across the Internet ADO.NET requires new mindset –All data access disconnected –All data transport uses XML

What Is ADO.NET? ADO.NET is a collection of classes, interfaces, structures, and enumerated types that manage data access from relational data stores within the.NET Framework.These collections are organized into namespaces: System.Data, System.Data.OleDb ADO.NET is an evolution from ADO. –Does not share the same object model, but shares many of the same paradigms and functionality!

ADO.NET Architecture Business Tier Data Tier Presentation Tier Windows Forms Web Forms Business to Business Data Object (Class) DataSet Internet Intranet Data Adapter (BizTalk, for example) XML MyApp.Exe IE

Namespace Architechture  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

ADO.NET ADO.NET-related Namespaces System.Data.OleDb.SqlClient.SqlTypes.Common

ADO.NET Application ODBC Driver ODBCRDBMS ODBC OLE DB RDBMS.NET Data Provider Connection Command Data Reader Data Adapter OLE DB OLE DB Provider SQL Server

Classes : System.Data Constraint DataColoumn DataException DataRelation DataRow DataRowBuilder DataSet DataTable DataTableCollection DataView Entity key Entity Exception

Shared classes(System.data) Shared classes are actually the classes which are used regardless of type of Database engine we are accessing as sql,Oracle(oleDb)or access. –The class hierarchy is as : Constraint dataColoumn dataRelation dataRow dataSet dataTable

 Database specific classess are included in the system.data.sqlClient &.OleDB Database Specific Classes

Database Connectivity

Simple Example Connection Establishment –Pass all data in a string –Create a OLeDB/SQL connection/RDBMS connection –Create dataset and data Adapter to get and collect data –Now initialize the data table object(dataRow) to access the data.

DEMO

Using Database Connections Efficiently We use database connections by using: –Exception handling –Using Block Statement

Commands

Structure DbCommandOleDbCommand ExecuteReader ExecuteScalar ExeecuteNonQuery SqlCommand ExecuteReader ExecuteScalar ExeecuteNonQuery ExecuteXMLReader OdbcCommand ExecuteReader ExecuteScalar ExeecuteNonQuery OracleCommand ExecuteReader ExecuteScalar ExeecuteNonQuery

Command Object Properties CommandType Command Text Parameter Connection

Command Type Enumerations: –Text –StoredProcedure –TableDirect

Command Text Depends on CommandType Contains a string that represents either the command/query, procedure names or tables.

Parameters The Parameters property is a collection of zero or more appropriate DbParameter instances. The use of the Parameters property is only necessary if the CommandText property holds a parameterized query.

Parameters(2) SqlParameter parameter = new SqlParameter(); parameter.ParameterName = parameter.SqlDbType = SqlDbType.NVarChar; parameter.Direction = ParameterDirection.Input; parameter.Value = categoryName; command.Parameters.Add(parameter);

Connection The Connection property of a command object must be set to an appropriate connection object.

Command Objects (2) Used to execute commands to a database across a data connection. Used to execute stored procedures, SQL commands or return complete table directories.

ExecuteNonQuery() Executes commands that have no return values, e.g. DDL and DML statements.

ExecuteScalar() Returns a single value from database query

ExecuteReader() Returns a DataReader object.

ExecuteXMLReader() Returns an XMLReader.

Stored Procedures Stored Procedures are a set of sql commands which are compiled and are stored inside the database. When executing a sql command, the command is parsed, optimization is done and then the command is executed.

Stored Procedures(2) Without a return parameter: –Creating a procedure Create PROCEDURE CreateRow AS INSERT into TABLE2 values (001, ‘Farooq’);

Stored Procedures(3) –Calling the procedure SqlConnection SqlConn1 = new SqlConnection(); SqlConn1.ConnectionString = “ ”; SqlCommand SqlComm1 = new SqlCommand(); SqlComm1.Connection = SqlConn1; SqlComm1.CommandType = CommandType.StoredProcedure; SqlComm1.CommandText = "CreateRow"; SqlConn1.Open(); SqlConn1.Close(); Console.ReadLine();

Stored Procedures(4) With a return parameter –Creating a procedure CREATE PROCEDURE CountRecords AS SELECT Count(*) from TABLE1

Stored Procedures(5) –Calling the procedure SqlConnection SqlConn1 = new SqlConnection(); SqlConn1.ConnectionString = “ ”; SqlCommand SqlComm1 = new SqlCommand(); SqlComm1.Connection = SqlConn1; SqlComm1.CommandType = CommandType.StoredProcedure; SqlComm1.CommandText = "CountRecords"; SqlConn1.Open(); Console.WriteLine("Calling the procedure returns :" + SqlComm1.ExecuteScalar()); SqlConn1.Close(); Console.ReadLine();

The Data Reader

DataReader Object The DataReader object provides a forward- only, read-only, connected stream recordset from a database. These objects cannot be directly instantiated. The SqlCommand.ExecuteReader method returns a SqlDataReader object. ted.

DataReader Object (2) The DataReader can provide rows of data directly to application logic when you do not need to keep the data cached in memory. Requires the exclusive use of an open Connection object for the lifetime of the DataReader.

THANK YOU