SlideShare a Scribd company logo
1 of 18
 A programming language does not understand syntax
and structure of other programming language but if it
is required to interact from one to another
programming language, there will be one mediator
which will help them to interact without any problem.
 ADO stands for active data object, which behaves as a
mediator between the client side and server side.
Client side can’t directly interact with the server side,
so there is ADO.NET which behaves as a mediator
between front end and back end as in the following
figure:
 The diagram shows that ADO.NET can be used with
any kind of application, i.e., it can be used from a
Windows Forms application, an ASP.NET application,
or from a WPF and/or Silverlight application.
 Also, the data store underneath can be any data store,
SQL Server, Access, or Oracle.
 It is just a matter of using the right set of classes
specific to that data store and the methodology will
remain the same.
In a typical scenario requiring data access, we need to
perform four major tasks:
 Connecting to the database
 Passing the request to the database, i.e., a command
like select, insert, or update.
 Getting back the results, i.e., rows and/or the number
of rows effected.
 Storing the result and displaying it to the user.
Classes in ADO.NET
ADO.NET is a group of class which contains.
 Connection
 Command
 Datareader
 DataAdapter
 Dataset
Connection
 Connection class used to establish the connection between
front end and back end
 The Connection class uses a ConnectionString to identify
the database server location, authentication parameters,
and other information to connect to the database.
Ex.
 SqlConnection con=new SqlConnection(“Integrated securi
ty=true;initial catalog=Student;Data source=.
 OR
 SqlConnection Con=new SqlConnection(“User id=sa;Pass
word=sa123;Database=Student;Server=.”);
Command
 Once we have the connection ready, the next step
would be to tell the database about what operation we
need to perform on the database.
 This can be done using the Command object.
 SqlCommand cmd=new SqlCommand(“Query which
has to perform”,Connection Object)
 cmd = con.CreateCommand(); // This will specify that
we are passing the stored procedures name
cmd.CommandType =
CommandType.StoredProcedure; cmd.CommandText
= CommandName; // This will be the stored procedures
name
 If the Stored Procedure is expecting some parameters
then we can pass these parameters by creating
instances of SqlParameter objects as:
SqlCommand cmd = con.CreateCommand(); // This will
specify that we are passing the stored procedures name
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = CommandName; // This will be
the stored procedures name SqlParameter param = new
SqlParameter("@id", txtSearch.Text);
cmd.Parameters.Add(param);
Passing a SQL query from an
application using a Command
 If we want to pass a SQL query from our application
then we can use the SqlCommand as:
 SqlCommand cmd = con.CreateCommand();
cmd.CommandType = CommandType.Text; //This will
specify that we are passing query from application
string query = "select * from Authors";
cmd.CommandText = query;
Storing the Result
 DataReader: DataReader used to read the data from
source.
 Dataset: DataSet contains the table and relation.
 DataAdapter: DataAdapter behave as mediator
between back end and front end. But it does not has
features to contains the data .So there is dataset which
contains the data of result set.
DataReader
 A DataReader is an object that can be used to access
the results sequentially from a database.
The DataReader is used to get forward only sequential
results as the query executes. This is used with the
Command object
Dataset
 The Dataset can be thought of as an in-memory
representation of a database.
 A DataSet is a disconnected data access object.
 The result of the query can be stored in a Dataset.
 The DataSet contains DataTables.
 The DataTables contain DataRow and DataColumns.
 A DataSet or a DataTable can be used with a
Command and a DataAdapter object to store query
results.
DataAdapter
 A DataAdapter object is used to fill
a DataSet/DataTable with query results.
 This can be thought of as the adapter between the
connected and disconnected data models.
 A Command object will be used to execute the query
and a DataAdapter will use this Command object and
fill the query results coming from the database into
a DataSet/DataTable

More Related Content

Similar to Csharp_dotnet_ADO_Net_database_query.pptx

Similar to Csharp_dotnet_ADO_Net_database_query.pptx (20)

Introduction to ado
Introduction to adoIntroduction to ado
Introduction to ado
 
Chapter 3: ado.net
Chapter 3: ado.netChapter 3: ado.net
Chapter 3: ado.net
 
Chap14 ado.net
Chap14 ado.netChap14 ado.net
Chap14 ado.net
 
Ado
AdoAdo
Ado
 
LECTURE 14 Data Access.pptx
LECTURE 14 Data Access.pptxLECTURE 14 Data Access.pptx
LECTURE 14 Data Access.pptx
 
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
 
Ch06 ado.net fundamentals
Ch06 ado.net fundamentalsCh06 ado.net fundamentals
Ch06 ado.net fundamentals
 
ADO .Net
ADO .Net ADO .Net
ADO .Net
 
ADO.NET
ADO.NETADO.NET
ADO.NET
 
PPT temp.pptx
PPT temp.pptxPPT temp.pptx
PPT temp.pptx
 
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
 
5.C#
5.C#5.C#
5.C#
 
Ado
AdoAdo
Ado
 
Chapter 15
Chapter 15Chapter 15
Chapter 15
 
unit 3.docx
unit 3.docxunit 3.docx
unit 3.docx
 
Asp.Net Database
Asp.Net DatabaseAsp.Net Database
Asp.Net Database
 
Session x(ado.net)
Session x(ado.net)Session x(ado.net)
Session x(ado.net)
 
Advance Java Practical file
Advance Java Practical fileAdvance Java Practical file
Advance Java Practical file
 
ADO.NET
ADO.NETADO.NET
ADO.NET
 

Recently uploaded

SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Neo4j
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDGMarianaLemus7
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 

Recently uploaded (20)

SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDG
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 

Csharp_dotnet_ADO_Net_database_query.pptx

  • 1.
  • 2.  A programming language does not understand syntax and structure of other programming language but if it is required to interact from one to another programming language, there will be one mediator which will help them to interact without any problem.
  • 3.  ADO stands for active data object, which behaves as a mediator between the client side and server side. Client side can’t directly interact with the server side, so there is ADO.NET which behaves as a mediator between front end and back end as in the following figure:
  • 4.
  • 5.  The diagram shows that ADO.NET can be used with any kind of application, i.e., it can be used from a Windows Forms application, an ASP.NET application, or from a WPF and/or Silverlight application.  Also, the data store underneath can be any data store, SQL Server, Access, or Oracle.  It is just a matter of using the right set of classes specific to that data store and the methodology will remain the same.
  • 6. In a typical scenario requiring data access, we need to perform four major tasks:  Connecting to the database  Passing the request to the database, i.e., a command like select, insert, or update.  Getting back the results, i.e., rows and/or the number of rows effected.  Storing the result and displaying it to the user.
  • 7.
  • 8. Classes in ADO.NET ADO.NET is a group of class which contains.  Connection  Command  Datareader  DataAdapter  Dataset
  • 9. Connection  Connection class used to establish the connection between front end and back end  The Connection class uses a ConnectionString to identify the database server location, authentication parameters, and other information to connect to the database. Ex.  SqlConnection con=new SqlConnection(“Integrated securi ty=true;initial catalog=Student;Data source=.  OR  SqlConnection Con=new SqlConnection(“User id=sa;Pass word=sa123;Database=Student;Server=.”);
  • 10. Command  Once we have the connection ready, the next step would be to tell the database about what operation we need to perform on the database.  This can be done using the Command object.
  • 11.  SqlCommand cmd=new SqlCommand(“Query which has to perform”,Connection Object)
  • 12.  cmd = con.CreateCommand(); // This will specify that we are passing the stored procedures name cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = CommandName; // This will be the stored procedures name
  • 13.  If the Stored Procedure is expecting some parameters then we can pass these parameters by creating instances of SqlParameter objects as: SqlCommand cmd = con.CreateCommand(); // This will specify that we are passing the stored procedures name cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = CommandName; // This will be the stored procedures name SqlParameter param = new SqlParameter("@id", txtSearch.Text); cmd.Parameters.Add(param);
  • 14. Passing a SQL query from an application using a Command  If we want to pass a SQL query from our application then we can use the SqlCommand as:  SqlCommand cmd = con.CreateCommand(); cmd.CommandType = CommandType.Text; //This will specify that we are passing query from application string query = "select * from Authors"; cmd.CommandText = query;
  • 15. Storing the Result  DataReader: DataReader used to read the data from source.  Dataset: DataSet contains the table and relation.  DataAdapter: DataAdapter behave as mediator between back end and front end. But it does not has features to contains the data .So there is dataset which contains the data of result set.
  • 16. DataReader  A DataReader is an object that can be used to access the results sequentially from a database. The DataReader is used to get forward only sequential results as the query executes. This is used with the Command object
  • 17. Dataset  The Dataset can be thought of as an in-memory representation of a database.  A DataSet is a disconnected data access object.  The result of the query can be stored in a Dataset.  The DataSet contains DataTables.  The DataTables contain DataRow and DataColumns.  A DataSet or a DataTable can be used with a Command and a DataAdapter object to store query results.
  • 18. DataAdapter  A DataAdapter object is used to fill a DataSet/DataTable with query results.  This can be thought of as the adapter between the connected and disconnected data models.  A Command object will be used to execute the query and a DataAdapter will use this Command object and fill the query results coming from the database into a DataSet/DataTable