SlideShare a Scribd company logo
Csharp_dotnet_ADO_Net_database_query.pptx
 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:
Csharp_dotnet_ADO_Net_database_query.pptx
 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.
Csharp_dotnet_ADO_Net_database_query.pptx
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

PDF
Ado.Net Architecture
PPT
Ado.net
PPTX
ADO.NET by ASP.NET Development Company in india
PDF
PPTX
Ado.net
PPTX
Ado.Net Tutorial
PPTX
Ch 7 data binding
PPT
ASP.NET Session 11 12
Ado.Net Architecture
Ado.net
ADO.NET by ASP.NET Development Company in india
Ado.net
Ado.Net Tutorial
Ch 7 data binding
ASP.NET Session 11 12

Similar to Csharp_dotnet_ADO_Net_database_query.pptx (20)

PPT
Introduction to ado
PDF
ADO.NET Interview Questions PDF By ScholarHat
PPTX
Chapter 3: ado.net
PPT
Chap14 ado.net
PPT
Chapter 4 event it theory programming.pptx
DOC
PPTX
LECTURE 14 Data Access.pptx
PPT
the .NET Framework. It provides the claf
PPTX
Ado.net
PPT
ASP.NET 09 - ADO.NET
PPTX
Ch06 ado.net fundamentals
PPT
ADO .Net
PPSX
ADO.NET
PPTX
PPT temp.pptx
PPTX
Disconnected Architecture and Crystal report in VB.NET
PPTX
PPTX
111111112222223333335555555666Unit-4.pptx
PPT
PPTX
DOCX
unit 3.docx
Introduction to ado
ADO.NET Interview Questions PDF By ScholarHat
Chapter 3: ado.net
Chap14 ado.net
Chapter 4 event it theory programming.pptx
LECTURE 14 Data Access.pptx
the .NET Framework. It provides the claf
Ado.net
ASP.NET 09 - ADO.NET
Ch06 ado.net fundamentals
ADO .Net
ADO.NET
PPT temp.pptx
Disconnected Architecture and Crystal report in VB.NET
111111112222223333335555555666Unit-4.pptx
unit 3.docx
Ad

Recently uploaded (20)

PDF
Review of recent advances in non-invasive hemoglobin estimation
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PPTX
MYSQL Presentation for SQL database connectivity
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
Machine learning based COVID-19 study performance prediction
PPTX
Spectroscopy.pptx food analysis technology
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
Cloud computing and distributed systems.
PDF
KodekX | Application Modernization Development
PPTX
sap open course for s4hana steps from ECC to s4
DOCX
The AUB Centre for AI in Media Proposal.docx
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Encapsulation theory and applications.pdf
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
cuic standard and advanced reporting.pdf
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Review of recent advances in non-invasive hemoglobin estimation
“AI and Expert System Decision Support & Business Intelligence Systems”
MYSQL Presentation for SQL database connectivity
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Machine learning based COVID-19 study performance prediction
Spectroscopy.pptx food analysis technology
Digital-Transformation-Roadmap-for-Companies.pptx
Cloud computing and distributed systems.
KodekX | Application Modernization Development
sap open course for s4hana steps from ECC to s4
The AUB Centre for AI in Media Proposal.docx
Programs and apps: productivity, graphics, security and other tools
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Encapsulation theory and applications.pdf
Advanced methodologies resolving dimensionality complications for autism neur...
cuic standard and advanced reporting.pdf
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Ad

Csharp_dotnet_ADO_Net_database_query.pptx

  • 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:
  • 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.
  • 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