SlideShare a Scribd company logo
LECTURE 6
ADO.NET Overview
What is ADO.NET
• ADO.NET (Active Data Objects) is the data access
component of the .NET Framework
• Used to develop data bound Windows Forms and Web Forms
• Like other components of the .NET Framework,
ADO.NET consists of a set of classes that
interact to provide the required functionality
• VS 2008 (and greater) and .NET 2.0 (and greater) make
development much easier
• ADO.NET classes are divided to two primary components
• Data Providers handle communication with the data source
• Data Sets represent the actual data from the data source
ADO.NET Object Model
• The primary objects in the ADO.NET object model
• The true reality of the class library is
considerably more complicated
Data Providers
• Data Provider components are specific to a data
source
• A generic provider that can communicate
with any OLE DB data source (Access etc)
• An SQL Server provider, optimized
for SQL Server 7, 2000 & 2005
• An ODBC provider that can communicate
with an ODBC data source (MySQL etc)
• An Oracle provider, optimized for access to Oracle
• Data Providers contain the same objects
• SqlConnection, OleDbConnection, OracleConnection etc
SqlConnection
The SqlConnection class is used to establish a
connection to a SQL Server database. The SqlConnection
class is used for opening connections, setting or
retrieving properties of a connection, or handling
connection-related events.
Connection objects represent the physical connections
to data sources
• Their properties determine the data provider,
the data source, the database to connect to
and the string to be used during connection
– Their methods are fairly simple. You can open
and close the connection, change the database
and manage transactions
SqlCommand
The SqlCommand class is used to execute SQL statements
or stored procedures against a SQL Server database. The
SqlCommand class can execute statements or stored
procedures that do not return values, or that return
single values, XML, or datareaders.
• Command objects can be executed against a connection
They are also used by DataAdapter objects to handle the
communication requirements of DataSet objects.
SqlDataReader
The SqlDataReader class provides forward-only, read-
only only access to a set of rows returned from a SQL
Server database. Datareader provide high-performance
access to read-only data and is the
best choice for accessing data to be displayed in
ASP.NET.
• DataReader objects can not be created directly
in code as they are constructed by calling the
ExecuteReader method of a Command object
SqlDataAdapter
The SqlDataAdapter class is used as a bridge between the
DataSet class and SQL Server. You can use the
SqlDataAdapter class to create a dataset from a given
SQL statement or stored procedure represented by a
SqlCommand instance, to update the back-end SQL Server
database based on the contents of a dataset, or to
insert rows into or delete rows from a SQL Server
database.
• It provides an automated bridge between
a Connection object and a DataSet object
• A DataAdapter object contains four Command
objects, one each, for SELECT, UPDATE,
INSERT and DELETE based SQL statements
Sample 1
SqlConnection com;
SqlTransaction tran;
try {
con = new SqlConnection(connectionString);
con.open();
tran = con.BeginTransaction();
SqlCommand cmd = new SqlCommand(“DELETE FROM Customers”, con);
cmd.Transaction = tran;
cmd.ExecuteNonQuery();
}
catch (SqlException ex) {
if(tran!=null) tran.Rollback();
}
finally {
if(con!=null) con.Close();
}
Sample 2
SqlConnection com;
SqlTransaction tran;
try {
con = new SqlConnection(connectionString);
con.open();
SqlCommand cmd = new SqlCommand(“SELECT * FROM Customers”, con);
SqlDataReader rdr = cmd.ExecuteReader();
while(rdr.Read())
{
Console.WriteLine(rdr[0]);
}
}
catch (SqlException ex) {
if(tran!=null) tran.Rollback();
}
finally {
if(rdr!=null) rdr.Close(); if(con!=null) con.Close();
}
Data Sets
• The DataSet object is a memory resident copy of data
• The DataSet can be considered a somewhat simplified
relational database as it models tables and any
relationships between them
• The DataSet is always disconnected from the data source
• The DataSet is composed of two primary objects
• The DataTableCollection, accessed
through the Tables property
• The DataRelationCollection, accessed
through the Relations property
…cont
• The member or child objects in the DataSet object
Sample 3
SqlConnection com;
SqlTransaction tran;
try {
con = new SqlConnection(connectionString);
con.open();
SqlCommand cmd = new SqlCommand(“SELECT * FROM Customers”, con);
SqlDataReader rdr = cmd.ExecuteReader();
DataTable tbl = new DataTable(“MYTABLE1”);
tbl.Load(rdr);
dataGridView1.DataSource = tbl;
}
catch (SqlException ex) {
if(tran!=null) tran.Rollback();
}
finally {
if(rdr!=null) rdr.Close(); if(con!=null) con.Close();
}
GridView picture
Summary
• ADO.NET is the data access component of .NET
Framework
• Classes are split between Data Providers and Data Sets

More Related Content

What's hot

ADO.NET -database connection
ADO.NET -database connectionADO.NET -database connection
ADO.NET -database connection
Anekwong Yoddumnern
 
ADO.NET
ADO.NETADO.NET
ADO.NET
Farzad Wadia
 
ADO .Net
ADO .Net ADO .Net
ADO .Net
DrSonali Vyas
 
Chapter 3: ado.net
Chapter 3: ado.netChapter 3: ado.net
Chapter 3: ado.net
Ngeam Soly
 
For Beginers - ADO.Net
For Beginers - ADO.NetFor Beginers - ADO.Net
For Beginers - ADO.Net
Snehal Harawande
 
Ado.net
Ado.netAdo.net
Ado.net
dina1985vlr
 
ADO.NET by ASP.NET Development Company in india
ADO.NET by ASP.NET  Development Company in indiaADO.NET by ASP.NET  Development Company in india
ADO.NET by ASP.NET Development Company in india
iFour Institute - Sustainable Learning
 
Understanding C# in .NET
Understanding C# in .NETUnderstanding C# in .NET
Understanding C# in .NET
mentorrbuddy
 
ASP.NET 09 - ADO.NET
ASP.NET 09 - ADO.NETASP.NET 09 - ADO.NET
ASP.NET 09 - ADO.NET
Randy Connolly
 
ASP.NET Session 11 12
ASP.NET Session 11 12ASP.NET Session 11 12
ASP.NET Session 11 12
Sisir Ghosh
 
ASP.Net Presentation Part2
ASP.Net Presentation Part2ASP.Net Presentation Part2
ASP.Net Presentation Part2
Neeraj Mathur
 
Ado.net
Ado.netAdo.net
Ch06 ado.net fundamentals
Ch06 ado.net fundamentalsCh06 ado.net fundamentals
Ch06 ado.net fundamentals
Madhuri Kavade
 
Marmagna desai
Marmagna desaiMarmagna desai
Marmagna desai
jmsthakur
 
ADO.net control
ADO.net controlADO.net control
ADO.net control
Paneliya Prince
 
Database programming in vb net
Database programming in vb netDatabase programming in vb net
Database programming in vb net
Zishan yousaf
 
Ado.net
Ado.netAdo.net
Ado.net
Vikas Trivedi
 
VISUAL BASIC .net data accesss vii
VISUAL BASIC .net data accesss viiVISUAL BASIC .net data accesss vii
VISUAL BASIC .net data accesss vii
argusacademy
 
Visual Basic.Net & Ado.Net
Visual Basic.Net & Ado.NetVisual Basic.Net & Ado.Net
Visual Basic.Net & Ado.Net
FaRid Adwa
 

What's hot (19)

ADO.NET -database connection
ADO.NET -database connectionADO.NET -database connection
ADO.NET -database connection
 
ADO.NET
ADO.NETADO.NET
ADO.NET
 
ADO .Net
ADO .Net ADO .Net
ADO .Net
 
Chapter 3: ado.net
Chapter 3: ado.netChapter 3: ado.net
Chapter 3: ado.net
 
For Beginers - ADO.Net
For Beginers - ADO.NetFor Beginers - ADO.Net
For Beginers - ADO.Net
 
Ado.net
Ado.netAdo.net
Ado.net
 
ADO.NET by ASP.NET Development Company in india
ADO.NET by ASP.NET  Development Company in indiaADO.NET by ASP.NET  Development Company in india
ADO.NET by ASP.NET Development Company in india
 
Understanding C# in .NET
Understanding C# in .NETUnderstanding C# in .NET
Understanding C# in .NET
 
ASP.NET 09 - ADO.NET
ASP.NET 09 - ADO.NETASP.NET 09 - ADO.NET
ASP.NET 09 - ADO.NET
 
ASP.NET Session 11 12
ASP.NET Session 11 12ASP.NET Session 11 12
ASP.NET Session 11 12
 
ASP.Net Presentation Part2
ASP.Net Presentation Part2ASP.Net Presentation Part2
ASP.Net Presentation Part2
 
Ado.net
Ado.netAdo.net
Ado.net
 
Ch06 ado.net fundamentals
Ch06 ado.net fundamentalsCh06 ado.net fundamentals
Ch06 ado.net fundamentals
 
Marmagna desai
Marmagna desaiMarmagna desai
Marmagna desai
 
ADO.net control
ADO.net controlADO.net control
ADO.net control
 
Database programming in vb net
Database programming in vb netDatabase programming in vb net
Database programming in vb net
 
Ado.net
Ado.netAdo.net
Ado.net
 
VISUAL BASIC .net data accesss vii
VISUAL BASIC .net data accesss viiVISUAL BASIC .net data accesss vii
VISUAL BASIC .net data accesss vii
 
Visual Basic.Net & Ado.Net
Visual Basic.Net & Ado.NetVisual Basic.Net & Ado.Net
Visual Basic.Net & Ado.Net
 

Similar to Lecture 6. ADO.NET Overview.

Ado
AdoAdo
Unit4
Unit4Unit4
Introduction to ado
Introduction to adoIntroduction to ado
Introduction to ado
Harman Bajwa
 
Ado.net
Ado.netAdo.net
Ado.net
pacatarpit
 
LECTURE 14 Data Access.pptx
LECTURE 14 Data Access.pptxLECTURE 14 Data Access.pptx
LECTURE 14 Data Access.pptx
AOmaAli
 
Ado.Net Architecture
Ado.Net ArchitectureAdo.Net Architecture
Ado.Net Architecture
Umar Farooq
 
Asp .Net Database Connectivity Presentation.pptx
Asp .Net Database Connectivity Presentation.pptxAsp .Net Database Connectivity Presentation.pptx
Asp .Net Database Connectivity Presentation.pptx
sridharu1981
 
Synapseindia dot net development chapter 8 asp dot net
Synapseindia dot net development  chapter 8 asp dot netSynapseindia dot net development  chapter 8 asp dot net
Synapseindia dot net development chapter 8 asp dot net
Synapseindiappsdevelopment
 
Chapter 15
Chapter 15Chapter 15
Data management with ado
Data management with adoData management with ado
Data management with ado
Dinesh kumar
 
Csharp_dotnet_ADO_Net_database_query.pptx
Csharp_dotnet_ADO_Net_database_query.pptxCsharp_dotnet_ADO_Net_database_query.pptx
Csharp_dotnet_ADO_Net_database_query.pptx
facebookrecovery1
 
Ado.Net
Ado.NetAdo.Net
Ado.Net
LiquidHub
 
Data Access Technologies
Data Access TechnologiesData Access Technologies
Data Access Technologies
Dimara Hakim
 
3-ADO.NET.pdf
3-ADO.NET.pdf3-ADO.NET.pdf
3-ADO.NET.pdf
ManalAg
 
Ado
AdoAdo
Ado dot net complete meterial (1)
Ado dot net complete meterial (1)Ado dot net complete meterial (1)
Ado dot net complete meterial (1)
Mubarak Hussain
 
ADO .NET by Sonu Vishwakarma
ADO .NET by Sonu VishwakarmaADO .NET by Sonu Vishwakarma
ADO .NET by Sonu Vishwakarma
Sonu Vishwakarma
 
Introduction to SQLite in Adobe AIR
Introduction to SQLite in Adobe AIRIntroduction to SQLite in Adobe AIR
Introduction to SQLite in Adobe AIR
Peter Elst
 

Similar to Lecture 6. ADO.NET Overview. (18)

Ado
AdoAdo
Ado
 
Unit4
Unit4Unit4
Unit4
 
Introduction to ado
Introduction to adoIntroduction to ado
Introduction to ado
 
Ado.net
Ado.netAdo.net
Ado.net
 
LECTURE 14 Data Access.pptx
LECTURE 14 Data Access.pptxLECTURE 14 Data Access.pptx
LECTURE 14 Data Access.pptx
 
Ado.Net Architecture
Ado.Net ArchitectureAdo.Net Architecture
Ado.Net Architecture
 
Asp .Net Database Connectivity Presentation.pptx
Asp .Net Database Connectivity Presentation.pptxAsp .Net Database Connectivity Presentation.pptx
Asp .Net Database Connectivity Presentation.pptx
 
Synapseindia dot net development chapter 8 asp dot net
Synapseindia dot net development  chapter 8 asp dot netSynapseindia dot net development  chapter 8 asp dot net
Synapseindia dot net development chapter 8 asp dot net
 
Chapter 15
Chapter 15Chapter 15
Chapter 15
 
Data management with ado
Data management with adoData management with ado
Data management with ado
 
Csharp_dotnet_ADO_Net_database_query.pptx
Csharp_dotnet_ADO_Net_database_query.pptxCsharp_dotnet_ADO_Net_database_query.pptx
Csharp_dotnet_ADO_Net_database_query.pptx
 
Ado.Net
Ado.NetAdo.Net
Ado.Net
 
Data Access Technologies
Data Access TechnologiesData Access Technologies
Data Access Technologies
 
3-ADO.NET.pdf
3-ADO.NET.pdf3-ADO.NET.pdf
3-ADO.NET.pdf
 
Ado
AdoAdo
Ado
 
Ado dot net complete meterial (1)
Ado dot net complete meterial (1)Ado dot net complete meterial (1)
Ado dot net complete meterial (1)
 
ADO .NET by Sonu Vishwakarma
ADO .NET by Sonu VishwakarmaADO .NET by Sonu Vishwakarma
ADO .NET by Sonu Vishwakarma
 
Introduction to SQLite in Adobe AIR
Introduction to SQLite in Adobe AIRIntroduction to SQLite in Adobe AIR
Introduction to SQLite in Adobe AIR
 

More from Alexey Furmanov

Лекция 9. Основы HTML. Часть 2.
Лекция 9. Основы HTML. Часть 2.Лекция 9. Основы HTML. Часть 2.
Лекция 9. Основы HTML. Часть 2.
Alexey Furmanov
 
Лекция 8. HTML основы. Часть 1.
Лекция 8. HTML основы. Часть 1.Лекция 8. HTML основы. Часть 1.
Лекция 8. HTML основы. Часть 1.
Alexey Furmanov
 
Лекция 5. Поисковые системы.
Лекция 5. Поисковые системы.Лекция 5. Поисковые системы.
Лекция 5. Поисковые системы.
Alexey Furmanov
 
Лекция 4. Почтовая система. Outlook.
Лекция 4. Почтовая система. Outlook.Лекция 4. Почтовая система. Outlook.
Лекция 4. Почтовая система. Outlook.
Alexey Furmanov
 
Лекция 2. IP-адресация.
Лекция 2. IP-адресация.Лекция 2. IP-адресация.
Лекция 2. IP-адресация.
Alexey Furmanov
 
Лекция 3. Браузеры (2009)
Лекция 3. Браузеры (2009)Лекция 3. Браузеры (2009)
Лекция 3. Браузеры (2009)
Alexey Furmanov
 
Лекция 10. Основы CSS.
Лекция 10. Основы CSS.Лекция 10. Основы CSS.
Лекция 10. Основы CSS.
Alexey Furmanov
 
Лекция 1. Модель OSI.
Лекция 1. Модель OSI.Лекция 1. Модель OSI.
Лекция 1. Модель OSI.
Alexey Furmanov
 
Lecture 4. MS SQL. DML Triggers
Lecture 4. MS SQL. DML TriggersLecture 4. MS SQL. DML Triggers
Lecture 4. MS SQL. DML Triggers
Alexey Furmanov
 
Lecture 3. MS SQL. Cursors.
Lecture 3. MS SQL. Cursors.Lecture 3. MS SQL. Cursors.
Lecture 3. MS SQL. Cursors.
Alexey Furmanov
 
Lecture 2. MS SQL. Stored procedures.
Lecture 2. MS SQL. Stored procedures.Lecture 2. MS SQL. Stored procedures.
Lecture 2. MS SQL. Stored procedures.
Alexey Furmanov
 
Lecture 5. MS SQL. Transactions
Lecture 5. MS SQL. TransactionsLecture 5. MS SQL. Transactions
Lecture 5. MS SQL. Transactions
Alexey Furmanov
 

More from Alexey Furmanov (12)

Лекция 9. Основы HTML. Часть 2.
Лекция 9. Основы HTML. Часть 2.Лекция 9. Основы HTML. Часть 2.
Лекция 9. Основы HTML. Часть 2.
 
Лекция 8. HTML основы. Часть 1.
Лекция 8. HTML основы. Часть 1.Лекция 8. HTML основы. Часть 1.
Лекция 8. HTML основы. Часть 1.
 
Лекция 5. Поисковые системы.
Лекция 5. Поисковые системы.Лекция 5. Поисковые системы.
Лекция 5. Поисковые системы.
 
Лекция 4. Почтовая система. Outlook.
Лекция 4. Почтовая система. Outlook.Лекция 4. Почтовая система. Outlook.
Лекция 4. Почтовая система. Outlook.
 
Лекция 2. IP-адресация.
Лекция 2. IP-адресация.Лекция 2. IP-адресация.
Лекция 2. IP-адресация.
 
Лекция 3. Браузеры (2009)
Лекция 3. Браузеры (2009)Лекция 3. Браузеры (2009)
Лекция 3. Браузеры (2009)
 
Лекция 10. Основы CSS.
Лекция 10. Основы CSS.Лекция 10. Основы CSS.
Лекция 10. Основы CSS.
 
Лекция 1. Модель OSI.
Лекция 1. Модель OSI.Лекция 1. Модель OSI.
Лекция 1. Модель OSI.
 
Lecture 4. MS SQL. DML Triggers
Lecture 4. MS SQL. DML TriggersLecture 4. MS SQL. DML Triggers
Lecture 4. MS SQL. DML Triggers
 
Lecture 3. MS SQL. Cursors.
Lecture 3. MS SQL. Cursors.Lecture 3. MS SQL. Cursors.
Lecture 3. MS SQL. Cursors.
 
Lecture 2. MS SQL. Stored procedures.
Lecture 2. MS SQL. Stored procedures.Lecture 2. MS SQL. Stored procedures.
Lecture 2. MS SQL. Stored procedures.
 
Lecture 5. MS SQL. Transactions
Lecture 5. MS SQL. TransactionsLecture 5. MS SQL. Transactions
Lecture 5. MS SQL. Transactions
 

Recently uploaded

Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
adhitya5119
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
Jean Carlos Nunes Paixão
 
How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
Celine George
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
Scholarhat
 
How to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 InventoryHow to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 Inventory
Celine George
 
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
GeorgeMilliken2
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
Nicholas Montgomery
 
BBR 2024 Summer Sessions Interview Training
BBR  2024 Summer Sessions Interview TrainingBBR  2024 Summer Sessions Interview Training
BBR 2024 Summer Sessions Interview Training
Katrina Pritchard
 
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UPLAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
RAHUL
 
Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5
sayalidalavi006
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
Celine George
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
Israel Genealogy Research Association
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
TechSoup
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
National Information Standards Organization (NISO)
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
David Douglas School District
 
Walmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdfWalmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdf
TechSoup
 
Life upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for studentLife upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for student
NgcHiNguyn25
 
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptxPengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Fajar Baskoro
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
Colégio Santa Teresinha
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
Celine George
 

Recently uploaded (20)

Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
 
How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
 
How to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 InventoryHow to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 Inventory
 
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
 
BBR 2024 Summer Sessions Interview Training
BBR  2024 Summer Sessions Interview TrainingBBR  2024 Summer Sessions Interview Training
BBR 2024 Summer Sessions Interview Training
 
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UPLAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
 
Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
 
Walmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdfWalmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdf
 
Life upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for studentLife upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for student
 
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptxPengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptx
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
 

Lecture 6. ADO.NET Overview.

  • 2. What is ADO.NET • ADO.NET (Active Data Objects) is the data access component of the .NET Framework • Used to develop data bound Windows Forms and Web Forms • Like other components of the .NET Framework, ADO.NET consists of a set of classes that interact to provide the required functionality • VS 2008 (and greater) and .NET 2.0 (and greater) make development much easier • ADO.NET classes are divided to two primary components • Data Providers handle communication with the data source • Data Sets represent the actual data from the data source
  • 3. ADO.NET Object Model • The primary objects in the ADO.NET object model • The true reality of the class library is considerably more complicated
  • 4. Data Providers • Data Provider components are specific to a data source • A generic provider that can communicate with any OLE DB data source (Access etc) • An SQL Server provider, optimized for SQL Server 7, 2000 & 2005 • An ODBC provider that can communicate with an ODBC data source (MySQL etc) • An Oracle provider, optimized for access to Oracle • Data Providers contain the same objects • SqlConnection, OleDbConnection, OracleConnection etc
  • 5. SqlConnection The SqlConnection class is used to establish a connection to a SQL Server database. The SqlConnection class is used for opening connections, setting or retrieving properties of a connection, or handling connection-related events. Connection objects represent the physical connections to data sources • Their properties determine the data provider, the data source, the database to connect to and the string to be used during connection – Their methods are fairly simple. You can open and close the connection, change the database and manage transactions
  • 6. SqlCommand The SqlCommand class is used to execute SQL statements or stored procedures against a SQL Server database. The SqlCommand class can execute statements or stored procedures that do not return values, or that return single values, XML, or datareaders. • Command objects can be executed against a connection They are also used by DataAdapter objects to handle the communication requirements of DataSet objects.
  • 7. SqlDataReader The SqlDataReader class provides forward-only, read- only only access to a set of rows returned from a SQL Server database. Datareader provide high-performance access to read-only data and is the best choice for accessing data to be displayed in ASP.NET. • DataReader objects can not be created directly in code as they are constructed by calling the ExecuteReader method of a Command object
  • 8. SqlDataAdapter The SqlDataAdapter class is used as a bridge between the DataSet class and SQL Server. You can use the SqlDataAdapter class to create a dataset from a given SQL statement or stored procedure represented by a SqlCommand instance, to update the back-end SQL Server database based on the contents of a dataset, or to insert rows into or delete rows from a SQL Server database. • It provides an automated bridge between a Connection object and a DataSet object • A DataAdapter object contains four Command objects, one each, for SELECT, UPDATE, INSERT and DELETE based SQL statements
  • 9. Sample 1 SqlConnection com; SqlTransaction tran; try { con = new SqlConnection(connectionString); con.open(); tran = con.BeginTransaction(); SqlCommand cmd = new SqlCommand(“DELETE FROM Customers”, con); cmd.Transaction = tran; cmd.ExecuteNonQuery(); } catch (SqlException ex) { if(tran!=null) tran.Rollback(); } finally { if(con!=null) con.Close(); }
  • 10. Sample 2 SqlConnection com; SqlTransaction tran; try { con = new SqlConnection(connectionString); con.open(); SqlCommand cmd = new SqlCommand(“SELECT * FROM Customers”, con); SqlDataReader rdr = cmd.ExecuteReader(); while(rdr.Read()) { Console.WriteLine(rdr[0]); } } catch (SqlException ex) { if(tran!=null) tran.Rollback(); } finally { if(rdr!=null) rdr.Close(); if(con!=null) con.Close(); }
  • 11. Data Sets • The DataSet object is a memory resident copy of data • The DataSet can be considered a somewhat simplified relational database as it models tables and any relationships between them • The DataSet is always disconnected from the data source • The DataSet is composed of two primary objects • The DataTableCollection, accessed through the Tables property • The DataRelationCollection, accessed through the Relations property
  • 12. …cont • The member or child objects in the DataSet object
  • 13. Sample 3 SqlConnection com; SqlTransaction tran; try { con = new SqlConnection(connectionString); con.open(); SqlCommand cmd = new SqlCommand(“SELECT * FROM Customers”, con); SqlDataReader rdr = cmd.ExecuteReader(); DataTable tbl = new DataTable(“MYTABLE1”); tbl.Load(rdr); dataGridView1.DataSource = tbl; } catch (SqlException ex) { if(tran!=null) tran.Rollback(); } finally { if(rdr!=null) rdr.Close(); if(con!=null) con.Close(); }
  • 15. Summary • ADO.NET is the data access component of .NET Framework • Classes are split between Data Providers and Data Sets