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)

PPSX
ADO.NET
Farzad Wadia
 
PPT
Ado.net
Iblesoft
 
PPT
Introduction to ADO.NET
rchakra
 
PPTX
Ado .net
Manish Singh
 
PPTX
Ado.Net Tutorial
prabhu rajendran
 
PPT
Ado.net
dina1985vlr
 
PPTX
Ch06 ado.net fundamentals
Madhuri Kavade
 
PPT
Chap14 ado.net
mentorrbuddy
 
PPTX
Ado.net
Om Prakash
 
PPT
ASP.NET 09 - ADO.NET
Randy Connolly
 
PPT
ASP.NET 08 - Data Binding And Representation
Randy Connolly
 
PPT
Ado.net & data persistence frameworks
Luis Goldster
 
PPT
ASP.NET Session 11 12
Sisir Ghosh
 
PPT
Database programming in vb net
Zishan yousaf
 
PPT
SQL Server 2005 CLR Integration
webhostingguy
 
PPTX
Ch 7 data binding
Madhuri Kavade
 
PDF
Data Binding
LAY Leangsros
 
PPT
ADO.net control
Paneliya Prince
 
PDF
Ado.net
Vikas Trivedi
 
PPT
Database Connection
John Joseph San Juan
 
ADO.NET
Farzad Wadia
 
Ado.net
Iblesoft
 
Introduction to ADO.NET
rchakra
 
Ado .net
Manish Singh
 
Ado.Net Tutorial
prabhu rajendran
 
Ado.net
dina1985vlr
 
Ch06 ado.net fundamentals
Madhuri Kavade
 
Chap14 ado.net
mentorrbuddy
 
Ado.net
Om Prakash
 
ASP.NET 09 - ADO.NET
Randy Connolly
 
ASP.NET 08 - Data Binding And Representation
Randy Connolly
 
Ado.net & data persistence frameworks
Luis Goldster
 
ASP.NET Session 11 12
Sisir Ghosh
 
Database programming in vb net
Zishan yousaf
 
SQL Server 2005 CLR Integration
webhostingguy
 
Ch 7 data binding
Madhuri Kavade
 
Data Binding
LAY Leangsros
 
ADO.net control
Paneliya Prince
 
Ado.net
Vikas Trivedi
 
Database Connection
John Joseph San Juan
 

Similar to 5.C# (20)

PPT
Introduction to ado
Harman Bajwa
 
PPT
Marmagna desai
jmsthakur
 
PDF
Unit4
Abha Damani
 
PPT
Data management with ado
Dinesh kumar
 
PPTX
76.pptx ajx ppt file for univercity of granted
hectortrading693
 
PPTX
Chapter 15
application developer
 
PPT
the .NET Framework. It provides the claf
TesfahunMaru1
 
PPTX
Ado.net
pacatarpit
 
PDF
Ado.Net Architecture
Umar Farooq
 
PDF
ADO.NET Interview Questions PDF By ScholarHat
Scholarhat
 
PPT
Chapter 4 event it theory programming.pptx
kmkkali41
 
PPTX
Csharp_dotnet_ADO_Net_database_query.pptx
facebookrecovery1
 
PPTX
Unit4.pptx Data Access File System Data
Priyanka Jadhav
 
PPT
Data Access Technologies
Dimara Hakim
 
PPT
2310 b 09
Krazy Koder
 
PPTX
Ado.net by Awais Majeed
Awais Majeed
 
PPTX
ADO.NETObjects
Wings Interactive
 
PDF
Presentation on the ADO.NET framework in C#
kittu57736
 
PPTX
ADO .NET by Sonu Vishwakarma
Sonu Vishwakarma
 
DOC
Ado
actacademy
 
Introduction to ado
Harman Bajwa
 
Marmagna desai
jmsthakur
 
Data management with ado
Dinesh kumar
 
76.pptx ajx ppt file for univercity of granted
hectortrading693
 
the .NET Framework. It provides the claf
TesfahunMaru1
 
Ado.net
pacatarpit
 
Ado.Net Architecture
Umar Farooq
 
ADO.NET Interview Questions PDF By ScholarHat
Scholarhat
 
Chapter 4 event it theory programming.pptx
kmkkali41
 
Csharp_dotnet_ADO_Net_database_query.pptx
facebookrecovery1
 
Unit4.pptx Data Access File System Data
Priyanka Jadhav
 
Data Access Technologies
Dimara Hakim
 
2310 b 09
Krazy Koder
 
Ado.net by Awais Majeed
Awais Majeed
 
ADO.NETObjects
Wings Interactive
 
Presentation on the ADO.NET framework in C#
kittu57736
 
ADO .NET by Sonu Vishwakarma
Sonu Vishwakarma
 
Ad

More from Raghu nath (20)

PPTX
Mongo db
Raghu nath
 
PDF
Ftp (file transfer protocol)
Raghu nath
 
PDF
MS WORD 2013
Raghu nath
 
PDF
Msword
Raghu nath
 
PDF
Ms word
Raghu nath
 
PDF
Javascript part1
Raghu nath
 
PDF
Regular expressions
Raghu nath
 
PDF
Selection sort
Raghu nath
 
PPTX
Binary search
Raghu nath
 
PPTX
JSON(JavaScript Object Notation)
Raghu nath
 
PDF
Stemming algorithms
Raghu nath
 
PPTX
Step by step guide to install dhcp role
Raghu nath
 
PPTX
Network essentials chapter 4
Raghu nath
 
PPTX
Network essentials chapter 3
Raghu nath
 
PPTX
Network essentials chapter 2
Raghu nath
 
PPTX
Network essentials - chapter 1
Raghu nath
 
PPTX
Python chapter 2
Raghu nath
 
PPTX
python chapter 1
Raghu nath
 
PPTX
Linux Shell Scripting
Raghu nath
 
PPTX
Perl
Raghu nath
 
Mongo db
Raghu nath
 
Ftp (file transfer protocol)
Raghu nath
 
MS WORD 2013
Raghu nath
 
Msword
Raghu nath
 
Ms word
Raghu nath
 
Javascript part1
Raghu nath
 
Regular expressions
Raghu nath
 
Selection sort
Raghu nath
 
Binary search
Raghu nath
 
JSON(JavaScript Object Notation)
Raghu nath
 
Stemming algorithms
Raghu nath
 
Step by step guide to install dhcp role
Raghu nath
 
Network essentials chapter 4
Raghu nath
 
Network essentials chapter 3
Raghu nath
 
Network essentials chapter 2
Raghu nath
 
Network essentials - chapter 1
Raghu nath
 
Python chapter 2
Raghu nath
 
python chapter 1
Raghu nath
 
Linux Shell Scripting
Raghu nath
 
Ad

Recently uploaded (20)

PDF
NewMind AI Weekly Chronicles – July’25, Week III
NewMind AI
 
PDF
Economic Impact of Data Centres to the Malaysian Economy
flintglobalapac
 
PPTX
cloud computing vai.pptx for the project
vaibhavdobariyal79
 
PDF
Make GenAI investments go further with the Dell AI Factory
Principled Technologies
 
PDF
Responsible AI and AI Ethics - By Sylvester Ebhonu
Sylvester Ebhonu
 
PDF
Data_Analytics_vs_Data_Science_vs_BI_by_CA_Suvidha_Chaplot.pdf
CA Suvidha Chaplot
 
PDF
The Future of Artificial Intelligence (AI)
Mukul
 
PDF
Researching The Best Chat SDK Providers in 2025
Ray Fields
 
PDF
TrustArc Webinar - Navigating Data Privacy in LATAM: Laws, Trends, and Compli...
TrustArc
 
PPTX
The Future of AI & Machine Learning.pptx
pritsen4700
 
PDF
Google I/O Extended 2025 Baku - all ppts
HusseinMalikMammadli
 
PPTX
Agile Chennai 18-19 July 2025 | Workshop - Enhancing Agile Collaboration with...
AgileNetwork
 
PPTX
IT Runs Better with ThousandEyes AI-driven Assurance
ThousandEyes
 
PPTX
Introduction to Flutter by Ayush Desai.pptx
ayushdesai204
 
PDF
The Future of Mobile Is Context-Aware—Are You Ready?
iProgrammer Solutions Private Limited
 
PDF
CIFDAQ's Market Wrap : Bears Back in Control?
CIFDAQ
 
PPTX
Agile Chennai 18-19 July 2025 Ideathon | AI Powered Microfinance Literacy Gui...
AgileNetwork
 
PDF
RAT Builders - How to Catch Them All [DeepSec 2024]
malmoeb
 
PDF
Trying to figure out MCP by actually building an app from scratch with open s...
Julien SIMON
 
PPTX
AI Code Generation Risks (Ramkumar Dilli, CIO, Myridius)
Priyanka Aash
 
NewMind AI Weekly Chronicles – July’25, Week III
NewMind AI
 
Economic Impact of Data Centres to the Malaysian Economy
flintglobalapac
 
cloud computing vai.pptx for the project
vaibhavdobariyal79
 
Make GenAI investments go further with the Dell AI Factory
Principled Technologies
 
Responsible AI and AI Ethics - By Sylvester Ebhonu
Sylvester Ebhonu
 
Data_Analytics_vs_Data_Science_vs_BI_by_CA_Suvidha_Chaplot.pdf
CA Suvidha Chaplot
 
The Future of Artificial Intelligence (AI)
Mukul
 
Researching The Best Chat SDK Providers in 2025
Ray Fields
 
TrustArc Webinar - Navigating Data Privacy in LATAM: Laws, Trends, and Compli...
TrustArc
 
The Future of AI & Machine Learning.pptx
pritsen4700
 
Google I/O Extended 2025 Baku - all ppts
HusseinMalikMammadli
 
Agile Chennai 18-19 July 2025 | Workshop - Enhancing Agile Collaboration with...
AgileNetwork
 
IT Runs Better with ThousandEyes AI-driven Assurance
ThousandEyes
 
Introduction to Flutter by Ayush Desai.pptx
ayushdesai204
 
The Future of Mobile Is Context-Aware—Are You Ready?
iProgrammer Solutions Private Limited
 
CIFDAQ's Market Wrap : Bears Back in Control?
CIFDAQ
 
Agile Chennai 18-19 July 2025 Ideathon | AI Powered Microfinance Literacy Gui...
AgileNetwork
 
RAT Builders - How to Catch Them All [DeepSec 2024]
malmoeb
 
Trying to figure out MCP by actually building an app from scratch with open s...
Julien SIMON
 
AI Code Generation Risks (Ramkumar Dilli, CIO, Myridius)
Priyanka Aash
 

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.