ado.net introduction

11
ADO.NET Yogendra Tamang

Upload: yogendra-tamang

Post on 21-Aug-2015

43 views

Category:

Education


0 download

TRANSCRIPT

Page 1: ADO.NET Introduction

ADO.NETYogendra Tamang

Page 2: ADO.NET Introduction

Introduction

• Data Access and Manipulation Protocol• Disconnected Data Architecture i.e data you work with is just a copy

of data in the actual database.• Objects are found on System.Data.dll

Page 3: ADO.NET Introduction

Features

• LINQ• LINQ to DAtaSet• LINQ to SQL

Page 4: ADO.NET Introduction

ADO.NET Objects

• The connection objects [SqlConnection Object]• Connection to datasource to read and write data with these objects

• DataAdapter Objects • Provides communication between datasource and dataset

• Command Object• Allows data adapters to read, add, update and delete records in datasource

• DataTable Object• Holds a data table from a datasource [Columns and Rows]

Page 5: ADO.NET Introduction

ADO.NET Objects

• Data Reader Objects• Holds read-only, forward only set of data from database.• Fast because only one row of data in a memory at a time.

• Data View Objects • Customized view of single object

• Constraint Object• Allows data adapters to read, add, update and delete records in datasource

• DataTable Object• Holds a data table from a datasource [Columns and Rows]

Page 6: ADO.NET Introduction

Data Providers in ADO.NET

• Set of related components that work together to provide data in efficient manner.• Connecting to DB, executing commands and retrieving results

OBJECTS• Connection• Command• DataReader• DataAdapter

Page 7: ADO.NET Introduction

DataSet

• In-memory representation of Data• Local copy of relevant portions of Database• Data in DataSet can be manipulated and updated

independent of the database.• Components of DataSet• DataTable• Stores data in table row format[DataRow and DataColumn]• NewRow() method for adding row to DataTable.

Page 8: ADO.NET Introduction

• Components of DataSet• DataView

Page 9: ADO.NET Introduction

DataReader

• Sequentially read the data from datasource.• Single row of data is loaded to memory at a time.• Commnad Object is used to retrieve data from database using

DataReader.• After Creating Command Object use command.ExecuteReader to

retrieve row of data from the database.• Use Read() method to read row from results of query.• Call Close() method when you finish using DataReader Object.

Page 10: ADO.NET Introduction

DataSet Or DataReader ????

Page 11: ADO.NET Introduction

DataAdapter