ado .net by sonu vishwakarma

21
SEMINAR ON ADO.NET Submitted by Sonu Vishwakarma Submitted to Mr. Saikat Banerjee Roll No. 1228710908 Mr. Ranvijay Singh

Upload: sonu-vishwakarma

Post on 24-May-2015

178 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: ADO .NET by Sonu Vishwakarma

SEMINAR ON

ADO.NET

Submitted by

Sonu Vishwakarma

Submitted to

Mr. Saikat BanerjeeRoll No. 1228710908

Mr. Ranvijay Singh

Page 2: ADO .NET by Sonu Vishwakarma

ACCESSING RELATIONAL DATA USING MICROSOFT

VISUAL STUDIO .NET

ADO.NET

Page 3: ADO .NET by Sonu Vishwakarma

OVERVIEW What is .NET? .NET History. Introduction to ADO .NET History of ADO .NET Using Namespaces The ADO.net object model What is DataSet Accessing the Data with ADO .NET Data Adapter Object Model Creating a DataAdapter Generating a DataSet Storing Multiple Tables What are List-Bound Controls?

Page 4: ADO .NET by Sonu Vishwakarma

.NET

It erases the boundaries between applications and the Internet. Instead of interacting with an application or a single Web site, .NET will connect the user to an array of computers and services that will exchange and combine objects and data.

A Microsoft operating system platform that incorporates applications, a suite of tools and services the company's Web strategy. There are four main principles of .NET from the perspective of the user:

Software will be rented as a hosted service over the Internet instead of purchased on a store shelf. Essentially, the Internet will be housing all your applications and data.

Users will have access to their information on the Internet from any device, anytime, anywhere.

Page 6: ADO .NET by Sonu Vishwakarma

INTRODUCTION

ADO Stand form ActiveX Data Object (Network Enable Technology).

It is use for the database connection during the web developing or software developing.

ADO.NET is a set of classes that expose data access services for .NET Framework programmers.

ADO.NET provides a rich set of components for creating distributed, data-sharing applications.

ADO.NET supports a variety of development needs, including the creation of front-end database clients and middle-tier business objects used by applications, tools, languages, or Internet browsers.

Page 7: ADO .NET by Sonu Vishwakarma

CONT…

ADO.NET provides a set of classes for working with data. ADO.NET provides:

An evolutionary, more flexible successor to ADO

A system designed for disconnected environments

A programming model with advanced XML support

A set of classes, interfaces, structures, and enumerations that manage data access from within the .NET Framework

Page 9: ADO .NET by Sonu Vishwakarma

WHAT'S NEW IN ADO.NET?

1.SqlClient Data provider:- Streaming support from SQL Server to an application supports

scenarios where data on the server is unstructured. Support has been added for asynchronous programming. Connection failures will now be logged in the extended events

log.

2.ADO.NET Entity Framework :-The .NET Framework 4.5 adds APIs that enable new scenarios

when working with the Entity Framework 5.0.

Page 10: ADO .NET by Sonu Vishwakarma

USING NAMESPACES Use the Imports or using

statement to import namespaces

Namespaces used with ADO.NET include: System.Data System.Data.SqlClient System.Data.OleDb

Imports System.DataImports System.Data.SqlClientImports System.DataImports System.Data.SqlClient

using System.Data;using System.Data.SqlClient;using System.Data;using System.Data.SqlClient;

Page 11: ADO .NET by Sonu Vishwakarma

DataSet

SQL Server .NET Data Provider

OLE DB .NET Data Provider

SQL Server 7.0(and later)

OLEDB sources(SQL Server 6.5)

OleDbConnectionOleDbConnection

OleDbDataAdapterOleDbDataAdapterSqlDataAdapterSqlDataAdapter

SqlConnectionSqlConnection

DataTable

DataTable

THE ADO.NET OBJECT MODEL

Page 12: ADO .NET by Sonu Vishwakarma

SQL Server 2000

DataSet

DataTable

DataTable

Physical storage

OleDb Database

SqlDataAdapterSqlDataAdapter

SqlConnectionSqlConnection

DataTable

Client/Web server memory

OleDbDataAdapterOleDbDataAdapter

OleDbConnectionOleDbConnection

WHAT IS A DATASET?

Page 13: ADO .NET by Sonu Vishwakarma

ACCESSING DATA WITH ADO.NET

Database

4. Return the DataSet to the Client

5. Client manipulates the data

2. Create the SqlConnection and SqlDataAdapter objects

3. Fill the DataSet from the DataAdapter and close the connection

SqlDataAdapter

SqlConnection

List-Bound

Control

List-Bound

Control

1. Client makes request11

22

33

44

55

6. Update the DataSet

7. Use the SqlDataAdapter to open the SqlConnection, update the database, and close the connection

66

77

ClientClient

Web serverWeb server

DataSet

Page 14: ADO .NET by Sonu Vishwakarma

THE DATAADAPTER OBJECT MODEL

sp_SELECT

CommandCommand

SelectCommand UpdateCommand InsertCommand DeleteCommand

DataAdapter

CommandCommand CommandCommand CommandCommand

ConnectionConnection

sp_UPDATE sp_INSERT sp_DELETE

Database

DataSetDataSet

DataReaderDataReader

Page 15: ADO .NET by Sonu Vishwakarma

Store the query in a DataAdapter

The DataAdapter constructor sets the SelectCommand property

Set the InsertCommand, UpdateCommand, and DeleteCommand properties if needed

CREATING A DATA ADAPTER

Dim da As New SqlDataAdapter _("select * from Authors", conn)

Dim da As New SqlDataAdapter _("select * from Authors", conn)

da.SelectCommand.CommandText da.SelectCommand.Connection

da.SelectCommand.CommandText da.SelectCommand.Connection

SqlDataAdapter da = new SqlDataAdapter("select * from Authors",conn);

SqlDataAdapter da = new SqlDataAdapter("select * from Authors",conn);

da.SelectCommand.CommandText;da.SelectCommand.Connection;

da.SelectCommand.CommandText;da.SelectCommand.Connection;

Page 16: ADO .NET by Sonu Vishwakarma

GENERATING A DATASET

You can generate a DataSet… …through the UI…

Creates a DataSet that allows you to access data as an object

…or through code…

and then fill…

Dim ds As New DataSet()Dim ds As New DataSet()

DataAdapter1.Fill(ds)DataAdapter2.Fill(ds)DataAdapter1.Fill(ds)DataAdapter2.Fill(ds)

DataSet ds = new DataSet();DataSet ds = new DataSet();

DataAdapter1.Fill(ds);DataAdapter2.Fill(ds);DataAdapter1.Fill(ds);DataAdapter2.Fill(ds);

Page 17: ADO .NET by Sonu Vishwakarma

STORING MULTIPLE TABLES Add the first table

Add the subsequent table(s)

daCustomers = New SqlDataAdapter _ ("select * from Customers", conn1)daCustomers.Fill(ds, "Customers")

daCustomers = New SqlDataAdapter _ ("select * from Customers", conn1)daCustomers.Fill(ds, "Customers")

Orders

Customers

daOrders = New SqlDataAdapter _ ("select * from Orders", conn2)daOrders.Fill(ds, "Orders")

daOrders = New SqlDataAdapter _ ("select * from Orders", conn2)daOrders.Fill(ds, "Orders")

conn2conn1

DataSet

Page 18: ADO .NET by Sonu Vishwakarma

WHAT ARE LIST-BOUND CONTROLS?

Controls that connect to a data source and display the data

List-bound controls include the following:

DropDownList

ListBox

CheckBoxList

RadioButtonList

DataGrid

DataList

Repeater

Page 19: ADO .NET by Sonu Vishwakarma

AN SQL EXAMPLE

<%@Page Language="c#"%><%@Import Namespace="System.Data" %><%@Import Namespace="System.Data.SqlClient" %><html><head> <title> ASP.NET - Data - Data Table <br/> Using Microsoft SQL Objects</title></head><body> <h2>Display of Data in a Table (Grid) Using SQL Objects</h2> Northwind Employees:<hr/> <asp:datagrid id="dgrEmployees" runat="server" /> <script Language="c#" runat="server">

Page 20: ADO .NET by Sonu Vishwakarma

So nice of you

Page 21: ADO .NET by Sonu Vishwakarma

Any think else?