SlideShare a Scribd company logo
Database Operations
ADO .net
 ADO.NET is the new database technology of the
.NET platform, and it builds on Microsoft
ActiveX® Data Objects (ADO).
 ADO.NET is a set of classes that expose data access
services to the .NET developer.
The ADO.NET classes are found inSystem.Data.dll
 ADO.NET is an primary part of the .NET
Framework, providing access to relational data,
Overview of ActiveX Data Objects
Data Provider
 Data Provider for SQL Server
(System.Data.SqlClient).
 The recommended data provider for SQL Server data
sources is SQL Server
 Data Provider for OLEDB (System.Data.OleDb).
 OLEDB is a COM-based API for database connections. Data
 Provider for ODBC (System.Data.Odbc).
 DODBC is an older standard and is actually not specific to
window you can get Unix-based ODBC
 Data Provider for Oracle (System.Data.OracleClient).
 oracle DB
Components of ADO
 Connection
object (SqlConnection, OleDbConnection, OdbcConnection,
OracleConnection)
 Namespace required
 using System.Data…. ;
 Connection String
 private string constr =" Initial Catalog=Northwind;" + "Data
Source=tempMYSQLSERVER;";
 Create instance of connection
 OleDbConnection con = new OleDbConnection(constr);
 Open Connection
 con.Open();
 Open a connection when you need it, and
 Close it as soon as you have finished with it.
Command
 Command
object (SqlCommand, OleDbCommand, OdbcCom
mand, OracleCommand)
 Deals with databases. It executes SQL commands on a
database. It sends an SQL command to a database that is
specified by an SqlConnection object. We then call instance
methods to physically apply the command to the database.
 ExecuteNonQuery() method
 Executes a SQL statement against the connection and returns the
number of rows affected.
DataReader
 DataReader
object (SqlDataReader, OleDbDataReader, OdbcDat
aReader, OracleDataReader)
 You use the Read method of the DataReader object to
obtain a row from the results of the query. You can access each
column of the returned row by passing the name or ordinal
reference of the column to the DataReader
 SqlDataReader reader = command.ExecuteReader();
Data Reader Sample code
SqlCommand command = new SqlCommand(
"SELECT CategoryID, CategoryName FROM Categories;",
connection);
connection.Open();
SqlDataReader reader = command.ExecuteReader();
if (reader.HasRows)
{
while (reader.Read())
{
Console.WriteLine("{0}t{1}", reader.GetInt32(0),
reader.GetString(1));
}
}
else
{
Console.WriteLine("No rows found.");
}
reader.Close();
DataAdapter
 DataAdapter object is like a bridge that links the database and
a Connection object with the ADO.NET-
managedDataSet object through its SELECT and action query
Commands. It specifies what data to move into and out of
theDataSet
 The DataAdapter provides four properties that allow us to
control how updates are made to the server:
 SelectCommand,UpdateCommand,InsertCommand,DeleteComman
 Fill (populates a DataSet with data).
 FillSchema (queries the database for schema information
that is necessary to update).
 Update (to change the database, DataAdapter calls
the DeleteCommand, the InsertCommand and
theUpdateCommand properties).
DataSet
 The DataSet is similar to an array of
disconnected Recordset objects. It supports disconnected
data access and operations, allowing greater scalability
because you no longer have to be connected to the
database all the time.DataSet is a copy of an extracted
data being downloaded and cached in the client system.
 DataTableCollection object containing null or
multiple DataTable objects (Columns, Rows,
Constraints).
 DataRelationCollection object containing null or
multiple DataRelation objects which establish a
parent/child relation between two DataTable objects.
DataGrid
 Windows Forms DataGrid control displays data in
a series of rows and columns.
 DataGridcontrol provides a user interface
to ADO.NET DataSets.
 displays tabular data and allows for updates to the
data source.
 DataGrid control to a valid data source
 Control will be automatically populated, creating
columns and rows based on the shape of the data.

More Related Content

What's hot (20)

ADO.NET
ADO.NETADO.NET
ADO.NET
 
Ado.net
Ado.netAdo.net
Ado.net
 
Introduction to ADO.NET
Introduction to ADO.NETIntroduction to ADO.NET
Introduction to ADO.NET
 
Ado .net
Ado .netAdo .net
Ado .net
 
Ado.Net Tutorial
Ado.Net TutorialAdo.Net Tutorial
Ado.Net Tutorial
 
Ado.net
Ado.netAdo.net
Ado.net
 
Ch06 ado.net fundamentals
Ch06 ado.net fundamentalsCh06 ado.net fundamentals
Ch06 ado.net fundamentals
 
Chap14 ado.net
Chap14 ado.netChap14 ado.net
Chap14 ado.net
 
Ado.net
Ado.netAdo.net
Ado.net
 
ASP.NET 09 - ADO.NET
ASP.NET 09 - ADO.NETASP.NET 09 - ADO.NET
ASP.NET 09 - ADO.NET
 
ASP.NET 08 - Data Binding And Representation
ASP.NET 08 - Data Binding And RepresentationASP.NET 08 - Data Binding And Representation
ASP.NET 08 - Data Binding And Representation
 
Ado.net & data persistence frameworks
Ado.net & data persistence frameworksAdo.net & data persistence frameworks
Ado.net & data persistence frameworks
 
ASP.NET Session 11 12
ASP.NET Session 11 12ASP.NET Session 11 12
ASP.NET Session 11 12
 
Database programming in vb net
Database programming in vb netDatabase programming in vb net
Database programming in vb net
 
SQL Server 2005 CLR Integration
SQL Server 2005 CLR IntegrationSQL Server 2005 CLR Integration
SQL Server 2005 CLR Integration
 
Ch 7 data binding
Ch 7 data bindingCh 7 data binding
Ch 7 data binding
 
Data Binding
Data BindingData Binding
Data Binding
 
ADO.net control
ADO.net controlADO.net control
ADO.net control
 
Ado.net
Ado.netAdo.net
Ado.net
 
Database Connection
Database ConnectionDatabase Connection
Database Connection
 

Similar to 5.C#

Introduction to ado
Introduction to adoIntroduction to ado
Introduction to ado
Harman Bajwa
 
Data management with ado
Data management with adoData management with ado
Data management with ado
Dinesh kumar
 
Data Access Technologies
Data Access TechnologiesData Access Technologies
Data Access Technologies
Dimara Hakim
 
ADO .NET by Sonu Vishwakarma
ADO .NET by Sonu VishwakarmaADO .NET by Sonu Vishwakarma
ADO .NET by Sonu Vishwakarma
Sonu Vishwakarma
 
Data base connectivity and flex grid in vb
Data base connectivity and flex grid in vbData base connectivity and flex grid in vb
Data base connectivity and flex grid in vb
Amandeep Kaur
 
jdbc_presentation.ppt
jdbc_presentation.pptjdbc_presentation.ppt
jdbc_presentation.ppt
DrMeenakshiS
 

Similar to 5.C# (20)

Introduction to ado
Introduction to adoIntroduction to ado
Introduction to ado
 
Marmagna desai
Marmagna desaiMarmagna desai
Marmagna desai
 
Unit4
Unit4Unit4
Unit4
 
Data management with ado
Data management with adoData management with ado
Data management with ado
 
Chapter 15
Chapter 15Chapter 15
Chapter 15
 
Ado.net
Ado.netAdo.net
Ado.net
 
Ado.Net Architecture
Ado.Net ArchitectureAdo.Net Architecture
Ado.Net Architecture
 
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
 
Data Access Technologies
Data Access TechnologiesData Access Technologies
Data Access Technologies
 
2310 b 09
2310 b 092310 b 09
2310 b 09
 
Ado.net by Awais Majeed
Ado.net by Awais MajeedAdo.net by Awais Majeed
Ado.net by Awais Majeed
 
ADO.NETObjects
ADO.NETObjectsADO.NETObjects
ADO.NETObjects
 
ADO .NET by Sonu Vishwakarma
ADO .NET by Sonu VishwakarmaADO .NET by Sonu Vishwakarma
ADO .NET by Sonu Vishwakarma
 
Ado
AdoAdo
Ado
 
Data base connectivity and flex grid in vb
Data base connectivity and flex grid in vbData base connectivity and flex grid in vb
Data base connectivity and flex grid in vb
 
Android sq lite-chapter 22
Android sq lite-chapter 22Android sq lite-chapter 22
Android sq lite-chapter 22
 
jdbc_presentation.ppt
jdbc_presentation.pptjdbc_presentation.ppt
jdbc_presentation.ppt
 
Jdbc 4.0 New Features And Enhancements
Jdbc 4.0 New Features And EnhancementsJdbc 4.0 New Features And Enhancements
Jdbc 4.0 New Features And Enhancements
 
Disconnected Architecture and Crystal report in VB.NET
Disconnected Architecture and Crystal report in VB.NETDisconnected Architecture and Crystal report in VB.NET
Disconnected Architecture and Crystal report in VB.NET
 
B_110500002
B_110500002B_110500002
B_110500002
 

More from Raghu nath

Ftp (file transfer protocol)
Ftp (file transfer protocol)Ftp (file transfer protocol)
Ftp (file transfer protocol)
Raghu nath
 
Javascript part1
Javascript part1Javascript part1
Javascript part1
Raghu nath
 
Regular expressions
Regular expressionsRegular expressions
Regular expressions
Raghu nath
 
Selection sort
Selection sortSelection sort
Selection sort
Raghu nath
 
Binary search
Binary search Binary search
Binary search
Raghu nath
 
JSON(JavaScript Object Notation)
JSON(JavaScript Object Notation)JSON(JavaScript Object Notation)
JSON(JavaScript Object Notation)
Raghu nath
 
Stemming algorithms
Stemming algorithmsStemming algorithms
Stemming algorithms
Raghu nath
 
Step by step guide to install dhcp role
Step by step guide to install dhcp roleStep by step guide to install dhcp role
Step by step guide to install dhcp role
Raghu nath
 
Network essentials chapter 4
Network essentials  chapter 4Network essentials  chapter 4
Network essentials chapter 4
Raghu nath
 
Network essentials chapter 3
Network essentials  chapter 3Network essentials  chapter 3
Network essentials chapter 3
Raghu nath
 
Network essentials chapter 2
Network essentials  chapter 2Network essentials  chapter 2
Network essentials chapter 2
Raghu nath
 
Network essentials - chapter 1
Network essentials - chapter 1Network essentials - chapter 1
Network essentials - chapter 1
Raghu nath
 
Python chapter 2
Python chapter 2Python chapter 2
Python chapter 2
Raghu nath
 
python chapter 1
python chapter 1python chapter 1
python chapter 1
Raghu nath
 
Linux Shell Scripting
Linux Shell ScriptingLinux Shell Scripting
Linux Shell Scripting
Raghu nath
 

More from Raghu nath (20)

Mongo db
Mongo dbMongo db
Mongo db
 
Ftp (file transfer protocol)
Ftp (file transfer protocol)Ftp (file transfer protocol)
Ftp (file transfer protocol)
 
MS WORD 2013
MS WORD 2013MS WORD 2013
MS WORD 2013
 
Msword
MswordMsword
Msword
 
Ms word
Ms wordMs word
Ms word
 
Javascript part1
Javascript part1Javascript part1
Javascript part1
 
Regular expressions
Regular expressionsRegular expressions
Regular expressions
 
Selection sort
Selection sortSelection sort
Selection sort
 
Binary search
Binary search Binary search
Binary search
 
JSON(JavaScript Object Notation)
JSON(JavaScript Object Notation)JSON(JavaScript Object Notation)
JSON(JavaScript Object Notation)
 
Stemming algorithms
Stemming algorithmsStemming algorithms
Stemming algorithms
 
Step by step guide to install dhcp role
Step by step guide to install dhcp roleStep by step guide to install dhcp role
Step by step guide to install dhcp role
 
Network essentials chapter 4
Network essentials  chapter 4Network essentials  chapter 4
Network essentials chapter 4
 
Network essentials chapter 3
Network essentials  chapter 3Network essentials  chapter 3
Network essentials chapter 3
 
Network essentials chapter 2
Network essentials  chapter 2Network essentials  chapter 2
Network essentials chapter 2
 
Network essentials - chapter 1
Network essentials - chapter 1Network essentials - chapter 1
Network essentials - chapter 1
 
Python chapter 2
Python chapter 2Python chapter 2
Python chapter 2
 
python chapter 1
python chapter 1python chapter 1
python chapter 1
 
Linux Shell Scripting
Linux Shell ScriptingLinux Shell Scripting
Linux Shell Scripting
 
Perl
PerlPerl
Perl
 

Recently uploaded

Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
Bhaskar Mitra
 

Recently uploaded (20)

The architecture of Generative AI for enterprises.pdf
The architecture of Generative AI for enterprises.pdfThe architecture of Generative AI for enterprises.pdf
The architecture of Generative AI for enterprises.pdf
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
Optimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through ObservabilityOptimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through Observability
 
Agentic RAG What it is its types applications and implementation.pdf
Agentic RAG What it is its types applications and implementation.pdfAgentic RAG What it is its types applications and implementation.pdf
Agentic RAG What it is its types applications and implementation.pdf
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
Speed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in MinutesSpeed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in Minutes
 
What's New in Teams Calling, Meetings and Devices April 2024
What's New in Teams Calling, Meetings and Devices April 2024What's New in Teams Calling, Meetings and Devices April 2024
What's New in Teams Calling, Meetings and Devices April 2024
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
AI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří KarpíšekAI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří Karpíšek
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
 
IoT Analytics Company Presentation May 2024
IoT Analytics Company Presentation May 2024IoT Analytics Company Presentation May 2024
IoT Analytics Company Presentation May 2024
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi IbrahimzadeFree and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
 
"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 

5.C#

  • 2. ADO .net  ADO.NET is the new database technology of the .NET platform, and it builds on Microsoft ActiveX® Data Objects (ADO).  ADO.NET is a set of classes that expose data access services to the .NET developer. The ADO.NET classes are found inSystem.Data.dll  ADO.NET is an primary part of the .NET Framework, providing access to relational data,
  • 3. Overview of ActiveX Data Objects
  • 4. Data Provider  Data Provider for SQL Server (System.Data.SqlClient).  The recommended data provider for SQL Server data sources is SQL Server  Data Provider for OLEDB (System.Data.OleDb).  OLEDB is a COM-based API for database connections. Data  Provider for ODBC (System.Data.Odbc).  DODBC is an older standard and is actually not specific to window you can get Unix-based ODBC  Data Provider for Oracle (System.Data.OracleClient).  oracle DB
  • 5. Components of ADO  Connection object (SqlConnection, OleDbConnection, OdbcConnection, OracleConnection)  Namespace required  using System.Data…. ;  Connection String  private string constr =" Initial Catalog=Northwind;" + "Data Source=tempMYSQLSERVER;";  Create instance of connection  OleDbConnection con = new OleDbConnection(constr);  Open Connection  con.Open();  Open a connection when you need it, and  Close it as soon as you have finished with it.
  • 6. Command  Command object (SqlCommand, OleDbCommand, OdbcCom mand, OracleCommand)  Deals with databases. It executes SQL commands on a database. It sends an SQL command to a database that is specified by an SqlConnection object. We then call instance methods to physically apply the command to the database.  ExecuteNonQuery() method  Executes a SQL statement against the connection and returns the number of rows affected.
  • 7. DataReader  DataReader object (SqlDataReader, OleDbDataReader, OdbcDat aReader, OracleDataReader)  You use the Read method of the DataReader object to obtain a row from the results of the query. You can access each column of the returned row by passing the name or ordinal reference of the column to the DataReader  SqlDataReader reader = command.ExecuteReader();
  • 8. Data Reader Sample code SqlCommand command = new SqlCommand( "SELECT CategoryID, CategoryName FROM Categories;", connection); connection.Open(); SqlDataReader reader = command.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { Console.WriteLine("{0}t{1}", reader.GetInt32(0), reader.GetString(1)); } } else { Console.WriteLine("No rows found."); } reader.Close();
  • 9. DataAdapter  DataAdapter object is like a bridge that links the database and a Connection object with the ADO.NET- managedDataSet object through its SELECT and action query Commands. It specifies what data to move into and out of theDataSet  The DataAdapter provides four properties that allow us to control how updates are made to the server:  SelectCommand,UpdateCommand,InsertCommand,DeleteComman  Fill (populates a DataSet with data).  FillSchema (queries the database for schema information that is necessary to update).  Update (to change the database, DataAdapter calls the DeleteCommand, the InsertCommand and theUpdateCommand properties).
  • 10. DataSet  The DataSet is similar to an array of disconnected Recordset objects. It supports disconnected data access and operations, allowing greater scalability because you no longer have to be connected to the database all the time.DataSet is a copy of an extracted data being downloaded and cached in the client system.  DataTableCollection object containing null or multiple DataTable objects (Columns, Rows, Constraints).  DataRelationCollection object containing null or multiple DataRelation objects which establish a parent/child relation between two DataTable objects.
  • 11. DataGrid  Windows Forms DataGrid control displays data in a series of rows and columns.  DataGridcontrol provides a user interface to ADO.NET DataSets.  displays tabular data and allows for updates to the data source.  DataGrid control to a valid data source  Control will be automatically populated, creating columns and rows based on the shape of the data.