SlideShare a Scribd company logo
iFour ConsultancyIntroduction to ADO. NET
 Introduction to ADO.NET
 Data Providers
 Classes
 SqlConnection Class
 SqlCommand Class
 SqlDataReader Class
 DataSet Class
 Connected architecture
 Disconnected architecture
 3-Tier Architecture
INDEX
http://www.ifourtechnolab.com/ ASP.NET Software Development Companies India
Introduction to ADO.NET : Definition
 Object-oriented set of libraries that allows interaction with data sources
 Commonly, the data source is a database, but it could also be a text file, an Excel
spreadsheet, or an XML file. It has classes and methods to retrieve and manipulate data
 It provides a bridge between the front end controls and the back end database
 The ADO.NET objects encapsulate all the data access operations and the controls
interaction with these objects to display data, thus hiding the details of movement of data
•A markup language is a set of markup tags
http://www.ifourtechnolab.com/ ASP.NET Software Development Companies India
Introduction to ADO.NET : Data Providers
 Provides a relatively common way to interact with data sources, but comes in different
sets of libraries for each way you can talk to a data source
 These libraries are called Data Providers and are usually named for the protocol or data
source type they allow you to interact with.
 Table shows data providers, the API prefix they use, and the type of data source they
allow you to interact with
Provider Name API prefix Data Source Description
ODBC Data Provider Odbc Data Sources with an ODBC interface. Normally older data bases
OleDb Data Provider OleDb Data Sources that expose an OleDb interface, i.e. Access or Excel
Oracle Data Provider Oracle For Oracle Databases
SQL Data Provider Sql For interacting with Microsoft SQL Server
Borland Data Provider Bdp Generic access to many databases such as Interbase, SQL Server, IBM DB2, and Oracle
http://www.ifourtechnolab.com/ ASP.NET Software Development Companies India
 SqlConnection Class
 SqlCommand Class
 SqlDataReader Class
 SqlDataAdaptor Class
 DataSet Class
Introduction to ADO.NET : Classes
http://www.ifourtechnolab.com/ ASP.NET Software Development Companies India
 To interact with a database, connection to database is must
 The connection helps identify the database server, the database name, user name,
password, and other parameters that are required for connecting to the data base
 A connection class object is used by command objects to know which database to execute
the command
Introduction to ADO.NET : SqlConnection Class
http://www.ifourtechnolab.com/ ASP.NET Software Development Companies India
 Add Connection String in Web config
<connectionStrings>
<add name="ConnectionName" connectionString="Data Source=192.168.0.27sql2014;Initial
Catalog=DatabaseName;Integrated Security=false;UID=username;PWD=Password;"
providerName="System.Data.SqlClient" />
</connectionStrings>
 Create A Connection Object
SqlConnection con=new
SqlConnection(ConfigurationManager.ConnectionStrings("ConnectionName").ConnectionString);
con.Open();
// Write Insert/Update/Delete/Select Query
con.Close()
SqlConnection Class - Example
http://www.ifourtechnolab.com/ ASP.NET Software Development Companies India
Used to send SQL statements to the database
It uses a connection object to figure out which database to communicate with
The Command class provides methods for storing and executing SQL statements and Stored
Procedures. The following are the various commands that are executed by the Command Class
 ExecuteReader: Returns data to the client as rows. This would typically be an SQL select statement or a
Stored Procedure that contains one or more select statements. This method returns a DataReader object
that can be used to fill a DataTable object or used directly for printing reports and so forth
 ExecuteNonQuery: Executes a command that changes the data in the database, such as an update,
delete, or insert statement, or a Stored Procedure that contains one or more of these statements. This
method returns an integer that is the number of rows affected by the query
 ExecuteScalar: Returns a single value. This kind of query returns a count of rows or a calculated value
 ExecuteXMLReader: (SqlClient classes only) Obtains data from an SQL Server 2000 database using an XML
stream. Returns an XML Reader object
Introduction to ADO.NET : SqlCommand Class
http://www.ifourtechnolab.com/ ASP.NET Software Development Companies India
 Creating a SqlCommand Object
 Similar to other C# objects, Instantiate a SqlCommand object via the new instance declaration, as follows:
 Querying Data
 When using a SQL select command, Retrieve a data set for viewing. To accomplish this with a SqlCommand object,
use the ExecuteReader method, which returns a SqlDataReader object. We’ll discuss the SqlDataReader in a future
lesson
 The example below shows how to use the SqlCommand object to obtain a SqlDataReader object:
SqlCommand Class – Example
http://www.ifourtechnolab.com/ ASP.NET Software Development Companies India
 Inserting Data
 To insert data into a database, use the ExecuteNonQuery method of the SqlCommand object.
The following code shows how to insert data into a database table:
SqlCommand Class – Example (Cont.)
http://www.ifourtechnolab.com/ ASP.NET Software Development Companies India
 Updating Data
 The ExecuteNonQuery method is also used for updating data. The following code shows how to
update data:
SqlCommand Class – Example (Cont.)
http://www.ifourtechnolab.com/ ASP.NET Software Development Companies India
 Deleting Data
 Delete data using the ExecuteNonQuery method. The following example shows how to delete a
record from a database with the ExecuteNonQuery method:
SqlCommand Class – Example (Cont.)
http://www.ifourtechnolab.com/ ASP.NET Software Development Companies India
 Getting Single values
 Sometimes need single value from database, which could be a count, sum, average, or other
aggregated value from a data set
 Performing an ExecuteReader and calculating the result in code is not the most efficient way to
do this
 The following example shows how to do this with the ExecuteScalar method:
SqlCommand Class – Example (Cont.)
http://www.ifourtechnolab.com/ ASP.NET Software Development Companies India
 Many data operations require reading only a stream of data
 This object allow to obtain the results of a SELECT statement from a command object
 For performance reasons, the data returned from a data reader is a fast forward-only
stream of data
 This means pull the data from the stream in a sequential manner This is good for speed,
but if need for manipulating data, then a DataSet is a better object to work with
Introduction to ADO.NET : SqlDataReader Class
http://www.ifourtechnolab.com/ ASP.NET Software Development Companies India
Creating a SqlDataReader Object
 Getting an instance of a SqlDataReader is a little different than the way other ADO.NET objects
are initialized. Call ExecuteReader on a command object, like this:
 The ExecuteReader method of the SqlCommand object, cmd , returns a SqlDataReader instance
 Creating a SqlDataReader with the new operator doesn’t do anything
 The SqlCommand object references the connection and the SQL statement necessary for the
SqlDataReader to obtain data
SqlDataReader Class - Example
http://www.ifourtechnolab.com/ ASP.NET Software Development Companies India
Reading Data
 The typical method of reading from the data stream returned by the SqlDataReader is to iterate
through each row with a while loop. The following code shows how to accomplish this:
SqlDataReader Class – Example (Cont.)
http://www.ifourtechnolab.com/ ASP.NET Software Development Companies India
 The data adapter makes it easy to accomplish these things by helping to manage data in a
disconnected mode
 The data adapter fills a DataSet object when reading the data and writes in a single batch when
persisting changes back to the database
 A data adapter contains a reference to the connection object and opens and closes the connection
automatically when reading from or writing to the database
 The data adapter contains command object references for SELECT, INSERT, UPDATE, and DELETE
operations on the data
 Data adapter defined for each table in a DataSet and it will take care of all communication with the
database
Introduction to ADO.NET : SqlDataAdaptor Class
http://www.ifourtechnolab.com/ ASP.NET Software Development Companies India
 Creating A SqlDataAdapter
 It holds the SQL commands and connection object for reading and writing data
 The code above creates a new SqlDataAdapter, daCustomers. The SQL select statement specifies
what data will be read into a DataSet
 The connection object, conn, should have already been instantiated, but not opened
 SqlDataAdapter’s responsibility to open and close the connection during Fill and Update method
calls
SqlDataAdaptor Class - Example
http://www.ifourtechnolab.com/ ASP.NET Software Development Companies India
 DataSet objects are in-memory representations of data
 Contains multiple Datatable objects, which contain columns and rows, just like normal
database tables. Possible to define relations between tables to create parent-child
relationships
 Specifically designed to help manage data in memory and to support disconnected
operations on data, when such a scenario makes sense
 An object that is used by all of the Data Providers, which is why it does not have a Data
Provider specific prefix
Introduction to ADO.NET : DataSet Class
http://www.ifourtechnolab.com/ ASP.NET Software Development Companies India
 Creating a DataSet Object
 There isn’t anything special about instantiating a DataSet. Create a new instance, just like any other object:
 Filling the DataSet
 Fill method of the SqlDataAdapter:
 The Fill method, in the code above, takes two parameters: a DataSet and a table name
 The DataSet must be instantiated before trying to fill it with data. The second parameter is the name of the table that
will be created in the DataSet
 Its purpose is to identify the table with a meaningful name later on. Typically, same name as the database table is
taken. However, if the SqlDataAdapter’s select command contains a join, need to find another meaningful name.
DataSet Class - Example
http://www.ifourtechnolab.com/ ASP.NET Software Development Companies India
 The architecture of ADO.net, in which connection must be opened to access the data
retrieved from database is called as connected architecture
 Built on the classes connection, command, datareader and transaction
 This creates more traffic to the database but is normally much faster for doing smaller
transactions
 Example:
Introduction to ADO.NET : Connected architecture
Database
Web Form
http://www.ifourtechnolab.com/ ASP.NET Software Development Companies India
 The architecture of ADO.net in which data retrieved from database can be accessed even when
connection to database was closed is called as disconnected architecture
 Built on classes connection, dataadapter, commandbuilder and dataset and dataview
 Method of retrieving a record set from the database and storing it giving the ability to do many
CRUD (Create, Read, Update and Delete) operations on the data in memory, then it can be re-
synchronized with the database when reconnecting
 Example:
Introduction to ADO.NET : Disconnected architecture
Database
Web Form
Data Adapter
http://www.ifourtechnolab.com/ ASP.NET Software Development Companies India
 A layer is a reusable portion of code that performs a specific function
 This specific layer is in charge of working with other layers to perform some specific goal
 Data Layer
 It contains methods that helps the Business Layer to connect the data and perform required actions, whether to
return data or to manipulate data (insert, update, delete)
 Business Layer
 A BAL contains business logic, validations or calculations related to the data. Though a website could talk to the
data access layer directly, it usually goes through another layer called the Business Layer.
 This ensures the data input is correct before proceeding, and can often ensure that the outputs are correct as well
 Presentation Layer
 Contains pages like .aspx or Windows Forms where data is presented to the user or input is taken from the user.
 The ASP.NET website or Windows Forms application (the UI for the project) is called the Presentation Layer. This is
the most important layer simply because it’s the one that everyone sees and uses
 Even with a well structured business and data layer, if the Presentation Layer is designed poorly, this gives the users
a poor view of the system
Introduction to ADO.NET : 3-Tier Architecture
http://www.ifourtechnolab.com/ ASP.NET Software Development Companies India
Graphical representation of 3-Tier Architecture
Introduction to ADO.NET : 3-Tier Architecture Example
UI
Asp.net
MVC
E.g.:
a=20;
B=10;
Store c;
BLL
C#.net
E.g.:
c=a+b;
DAL
ADO.NET
E.g.:
Output
c;
Database
E.g.: Ms Sqlserver
Presentation Layer
also called User
Interface. Computer,
Mobile phone,etc.
Business Logic Layer
Does all the logic
operations
Data Access Layer
Communicate with
the database
http://www.ifourtechnolab.com/ ASP.NET Software Development Companies India
 https://www.tutorialspoint.com/asp.net/asp.net_ado_net.htm
 https://msdn.microsoft.com/en-us/library/27y4ybxw(v=vs.110).aspx
 http://csharp-station.com/Tutorial/AdoDotNet
 https://msdn.microsoft.com/en-us/library/h43ks021(v=vs.110).aspx
References
http://www.ifourtechnolab.com/ ASP.NET Software Development Companies India
Questions?
http://www.ifourtechnolab.com/ ASP.NET Software Development Companies India

More Related Content

PPT
Ado.net
PPTX
Chapter 3: ado.net
PPT
ASP.NET 09 - ADO.NET
PPTX
ADO.NET -database connection
PPT
ADO.NET
PPT
Introduction to ADO.NET
PPT
ADO .Net
PPSX
ADO.NET
Ado.net
Chapter 3: ado.net
ASP.NET 09 - ADO.NET
ADO.NET -database connection
ADO.NET
Introduction to ADO.NET
ADO .Net
ADO.NET

What's hot (20)

PPTX
For Beginners - Ado.net
PPT
For Beginers - ADO.Net
PPTX
Ado .net
PPT
Ado.net
PPTX
Ado.Net Tutorial
PPTX
Ado.net
PPTX
Ch06 ado.net fundamentals
PPT
Chap14 ado.net
PDF
Visual Basic.Net & Ado.Net
PPT
Ado.net &amp; data persistence frameworks
PPS
Vb.net session 05
PDF
Ado.net
PPT
Database programming in vb net
PPT
Database Connection
PPTX
Ch 7 data binding
PPT
ASP.NET 08 - Data Binding And Representation
PPT
Dealing with SQL Security from ADO.NET
PPT
Marmagna desai
PPT
ASP.NET Session 11 12
PPTX
Disconnected Architecture and Crystal report in VB.NET
For Beginners - Ado.net
For Beginers - ADO.Net
Ado .net
Ado.net
Ado.Net Tutorial
Ado.net
Ch06 ado.net fundamentals
Chap14 ado.net
Visual Basic.Net & Ado.Net
Ado.net &amp; data persistence frameworks
Vb.net session 05
Ado.net
Database programming in vb net
Database Connection
Ch 7 data binding
ASP.NET 08 - Data Binding And Representation
Dealing with SQL Security from ADO.NET
Marmagna desai
ASP.NET Session 11 12
Disconnected Architecture and Crystal report in VB.NET
Ad

Viewers also liked (16)

PPS
Vb net xp_05
PPS
Ado.net session01
ODP
Advanced JavaScript Techniques
PDF
eXo EC - LaTeX
PDF
Is Your Agile Lean Enough
PPTX
Macro teradata
PPT
Object Oriented Programming In .Net
PPTX
MVC by asp.net development company in india
PPTX
Stored procedure
PPTX
Web API with ASP.NET MVC by Software development company in india
PDF
SpringPeople Building Web Sites with ASP.NET MVC FRAMEWORK
PDF
Stored-Procedures-Presentation
PPTX
ASP.NET MVC Performance
PPTX
Introduction to ASP.NET
PPTX
Introduction to VB.NET - UP SITF
Vb net xp_05
Ado.net session01
Advanced JavaScript Techniques
eXo EC - LaTeX
Is Your Agile Lean Enough
Macro teradata
Object Oriented Programming In .Net
MVC by asp.net development company in india
Stored procedure
Web API with ASP.NET MVC by Software development company in india
SpringPeople Building Web Sites with ASP.NET MVC FRAMEWORK
Stored-Procedures-Presentation
ASP.NET MVC Performance
Introduction to ASP.NET
Introduction to VB.NET - UP SITF
Ad

Similar to ADO.NET by ASP.NET Development Company in india (20)

PDF
ADO.NET Interview Questions PDF By ScholarHat
PPT
Introduction to ado
PPTX
Ado.net
PPTX
Csharp_dotnet_ADO_Net_database_query.pptx
PDF
Ado.Net Architecture
DOCX
unit 3.docx
PDF
PPT
Lecture 6. ADO.NET Overview.
PPTX
PPTX
Asp .Net Database Connectivity Presentation.pptx
PPTX
PPT temp.pptx
PPT
Chapter 4 event it theory programming.pptx
PPTX
111111112222223333335555555666Unit-4.pptx
DOCX
Simple ado program by visual studio
DOCX
Simple ado program by visual studio
PPT
the .NET Framework. It provides the claf
DOCX
MCS,BCS-7(A,B) Visual programming Syllabus for Final exams @ ISP
PDF
Presentation on the ADO.NET framework in C#
PPTX
PPTX
ADO .NET by Sonu Vishwakarma
ADO.NET Interview Questions PDF By ScholarHat
Introduction to ado
Ado.net
Csharp_dotnet_ADO_Net_database_query.pptx
Ado.Net Architecture
unit 3.docx
Lecture 6. ADO.NET Overview.
Asp .Net Database Connectivity Presentation.pptx
PPT temp.pptx
Chapter 4 event it theory programming.pptx
111111112222223333335555555666Unit-4.pptx
Simple ado program by visual studio
Simple ado program by visual studio
the .NET Framework. It provides the claf
MCS,BCS-7(A,B) Visual programming Syllabus for Final exams @ ISP
Presentation on the ADO.NET framework in C#
ADO .NET by Sonu Vishwakarma

More from iFour Institute - Sustainable Learning (10)

PPTX
Project Management : Project Planning by iFour Technolab Pvt. Ltd.
PPTX
Project management : Project Monitoring and Control by iFour Technolab Pvt. Ltd.
PPTX
Project management : Causal analysis and Resolution by iFour Technolab Pvt. ...
PPTX
Here are proven techniques to Organizing effective training by iFour Technola...
PPTX
PPTX
Mvc by asp.net development company in india - part 2
PPTX
PPTX
jQuery for web development
PPTX
Cascading style sheets - CSS
PPTX
HTML Basics by software development company india
Project Management : Project Planning by iFour Technolab Pvt. Ltd.
Project management : Project Monitoring and Control by iFour Technolab Pvt. Ltd.
Project management : Causal analysis and Resolution by iFour Technolab Pvt. ...
Here are proven techniques to Organizing effective training by iFour Technola...
Mvc by asp.net development company in india - part 2
jQuery for web development
Cascading style sheets - CSS
HTML Basics by software development company india

Recently uploaded (20)

PDF
Design an Analysis of Algorithms I-SECS-1021-03
PDF
Designing Intelligence for the Shop Floor.pdf
DOCX
Greta — No-Code AI for Building Full-Stack Web & Mobile Apps
PPTX
Operating system designcfffgfgggggggvggggggggg
PDF
CCleaner Pro 6.38.11537 Crack Final Latest Version 2025
PDF
medical staffing services at VALiNTRY
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PPTX
Reimagine Home Health with the Power of Agentic AI​
PDF
Nekopoi APK 2025 free lastest update
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PPTX
Why Generative AI is the Future of Content, Code & Creativity?
PPTX
Transform Your Business with a Software ERP System
PDF
Download FL Studio Crack Latest version 2025 ?
PPTX
AMADEUS TRAVEL AGENT SOFTWARE | AMADEUS TICKETING SYSTEM
PPTX
Patient Appointment Booking in Odoo with online payment
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PPTX
Advanced SystemCare Ultimate Crack + Portable (2025)
PPTX
assetexplorer- product-overview - presentation
PDF
Tally Prime Crack Download New Version 5.1 [2025] (License Key Free
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
Design an Analysis of Algorithms I-SECS-1021-03
Designing Intelligence for the Shop Floor.pdf
Greta — No-Code AI for Building Full-Stack Web & Mobile Apps
Operating system designcfffgfgggggggvggggggggg
CCleaner Pro 6.38.11537 Crack Final Latest Version 2025
medical staffing services at VALiNTRY
Wondershare Filmora 15 Crack With Activation Key [2025
Reimagine Home Health with the Power of Agentic AI​
Nekopoi APK 2025 free lastest update
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Why Generative AI is the Future of Content, Code & Creativity?
Transform Your Business with a Software ERP System
Download FL Studio Crack Latest version 2025 ?
AMADEUS TRAVEL AGENT SOFTWARE | AMADEUS TICKETING SYSTEM
Patient Appointment Booking in Odoo with online payment
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
Advanced SystemCare Ultimate Crack + Portable (2025)
assetexplorer- product-overview - presentation
Tally Prime Crack Download New Version 5.1 [2025] (License Key Free
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus

ADO.NET by ASP.NET Development Company in india

  • 2.  Introduction to ADO.NET  Data Providers  Classes  SqlConnection Class  SqlCommand Class  SqlDataReader Class  DataSet Class  Connected architecture  Disconnected architecture  3-Tier Architecture INDEX http://www.ifourtechnolab.com/ ASP.NET Software Development Companies India
  • 3. Introduction to ADO.NET : Definition  Object-oriented set of libraries that allows interaction with data sources  Commonly, the data source is a database, but it could also be a text file, an Excel spreadsheet, or an XML file. It has classes and methods to retrieve and manipulate data  It provides a bridge between the front end controls and the back end database  The ADO.NET objects encapsulate all the data access operations and the controls interaction with these objects to display data, thus hiding the details of movement of data •A markup language is a set of markup tags http://www.ifourtechnolab.com/ ASP.NET Software Development Companies India
  • 4. Introduction to ADO.NET : Data Providers  Provides a relatively common way to interact with data sources, but comes in different sets of libraries for each way you can talk to a data source  These libraries are called Data Providers and are usually named for the protocol or data source type they allow you to interact with.  Table shows data providers, the API prefix they use, and the type of data source they allow you to interact with Provider Name API prefix Data Source Description ODBC Data Provider Odbc Data Sources with an ODBC interface. Normally older data bases OleDb Data Provider OleDb Data Sources that expose an OleDb interface, i.e. Access or Excel Oracle Data Provider Oracle For Oracle Databases SQL Data Provider Sql For interacting with Microsoft SQL Server Borland Data Provider Bdp Generic access to many databases such as Interbase, SQL Server, IBM DB2, and Oracle http://www.ifourtechnolab.com/ ASP.NET Software Development Companies India
  • 5.  SqlConnection Class  SqlCommand Class  SqlDataReader Class  SqlDataAdaptor Class  DataSet Class Introduction to ADO.NET : Classes http://www.ifourtechnolab.com/ ASP.NET Software Development Companies India
  • 6.  To interact with a database, connection to database is must  The connection helps identify the database server, the database name, user name, password, and other parameters that are required for connecting to the data base  A connection class object is used by command objects to know which database to execute the command Introduction to ADO.NET : SqlConnection Class http://www.ifourtechnolab.com/ ASP.NET Software Development Companies India
  • 7.  Add Connection String in Web config <connectionStrings> <add name="ConnectionName" connectionString="Data Source=192.168.0.27sql2014;Initial Catalog=DatabaseName;Integrated Security=false;UID=username;PWD=Password;" providerName="System.Data.SqlClient" /> </connectionStrings>  Create A Connection Object SqlConnection con=new SqlConnection(ConfigurationManager.ConnectionStrings("ConnectionName").ConnectionString); con.Open(); // Write Insert/Update/Delete/Select Query con.Close() SqlConnection Class - Example http://www.ifourtechnolab.com/ ASP.NET Software Development Companies India
  • 8. Used to send SQL statements to the database It uses a connection object to figure out which database to communicate with The Command class provides methods for storing and executing SQL statements and Stored Procedures. The following are the various commands that are executed by the Command Class  ExecuteReader: Returns data to the client as rows. This would typically be an SQL select statement or a Stored Procedure that contains one or more select statements. This method returns a DataReader object that can be used to fill a DataTable object or used directly for printing reports and so forth  ExecuteNonQuery: Executes a command that changes the data in the database, such as an update, delete, or insert statement, or a Stored Procedure that contains one or more of these statements. This method returns an integer that is the number of rows affected by the query  ExecuteScalar: Returns a single value. This kind of query returns a count of rows or a calculated value  ExecuteXMLReader: (SqlClient classes only) Obtains data from an SQL Server 2000 database using an XML stream. Returns an XML Reader object Introduction to ADO.NET : SqlCommand Class http://www.ifourtechnolab.com/ ASP.NET Software Development Companies India
  • 9.  Creating a SqlCommand Object  Similar to other C# objects, Instantiate a SqlCommand object via the new instance declaration, as follows:  Querying Data  When using a SQL select command, Retrieve a data set for viewing. To accomplish this with a SqlCommand object, use the ExecuteReader method, which returns a SqlDataReader object. We’ll discuss the SqlDataReader in a future lesson  The example below shows how to use the SqlCommand object to obtain a SqlDataReader object: SqlCommand Class – Example http://www.ifourtechnolab.com/ ASP.NET Software Development Companies India
  • 10.  Inserting Data  To insert data into a database, use the ExecuteNonQuery method of the SqlCommand object. The following code shows how to insert data into a database table: SqlCommand Class – Example (Cont.) http://www.ifourtechnolab.com/ ASP.NET Software Development Companies India
  • 11.  Updating Data  The ExecuteNonQuery method is also used for updating data. The following code shows how to update data: SqlCommand Class – Example (Cont.) http://www.ifourtechnolab.com/ ASP.NET Software Development Companies India
  • 12.  Deleting Data  Delete data using the ExecuteNonQuery method. The following example shows how to delete a record from a database with the ExecuteNonQuery method: SqlCommand Class – Example (Cont.) http://www.ifourtechnolab.com/ ASP.NET Software Development Companies India
  • 13.  Getting Single values  Sometimes need single value from database, which could be a count, sum, average, or other aggregated value from a data set  Performing an ExecuteReader and calculating the result in code is not the most efficient way to do this  The following example shows how to do this with the ExecuteScalar method: SqlCommand Class – Example (Cont.) http://www.ifourtechnolab.com/ ASP.NET Software Development Companies India
  • 14.  Many data operations require reading only a stream of data  This object allow to obtain the results of a SELECT statement from a command object  For performance reasons, the data returned from a data reader is a fast forward-only stream of data  This means pull the data from the stream in a sequential manner This is good for speed, but if need for manipulating data, then a DataSet is a better object to work with Introduction to ADO.NET : SqlDataReader Class http://www.ifourtechnolab.com/ ASP.NET Software Development Companies India
  • 15. Creating a SqlDataReader Object  Getting an instance of a SqlDataReader is a little different than the way other ADO.NET objects are initialized. Call ExecuteReader on a command object, like this:  The ExecuteReader method of the SqlCommand object, cmd , returns a SqlDataReader instance  Creating a SqlDataReader with the new operator doesn’t do anything  The SqlCommand object references the connection and the SQL statement necessary for the SqlDataReader to obtain data SqlDataReader Class - Example http://www.ifourtechnolab.com/ ASP.NET Software Development Companies India
  • 16. Reading Data  The typical method of reading from the data stream returned by the SqlDataReader is to iterate through each row with a while loop. The following code shows how to accomplish this: SqlDataReader Class – Example (Cont.) http://www.ifourtechnolab.com/ ASP.NET Software Development Companies India
  • 17.  The data adapter makes it easy to accomplish these things by helping to manage data in a disconnected mode  The data adapter fills a DataSet object when reading the data and writes in a single batch when persisting changes back to the database  A data adapter contains a reference to the connection object and opens and closes the connection automatically when reading from or writing to the database  The data adapter contains command object references for SELECT, INSERT, UPDATE, and DELETE operations on the data  Data adapter defined for each table in a DataSet and it will take care of all communication with the database Introduction to ADO.NET : SqlDataAdaptor Class http://www.ifourtechnolab.com/ ASP.NET Software Development Companies India
  • 18.  Creating A SqlDataAdapter  It holds the SQL commands and connection object for reading and writing data  The code above creates a new SqlDataAdapter, daCustomers. The SQL select statement specifies what data will be read into a DataSet  The connection object, conn, should have already been instantiated, but not opened  SqlDataAdapter’s responsibility to open and close the connection during Fill and Update method calls SqlDataAdaptor Class - Example http://www.ifourtechnolab.com/ ASP.NET Software Development Companies India
  • 19.  DataSet objects are in-memory representations of data  Contains multiple Datatable objects, which contain columns and rows, just like normal database tables. Possible to define relations between tables to create parent-child relationships  Specifically designed to help manage data in memory and to support disconnected operations on data, when such a scenario makes sense  An object that is used by all of the Data Providers, which is why it does not have a Data Provider specific prefix Introduction to ADO.NET : DataSet Class http://www.ifourtechnolab.com/ ASP.NET Software Development Companies India
  • 20.  Creating a DataSet Object  There isn’t anything special about instantiating a DataSet. Create a new instance, just like any other object:  Filling the DataSet  Fill method of the SqlDataAdapter:  The Fill method, in the code above, takes two parameters: a DataSet and a table name  The DataSet must be instantiated before trying to fill it with data. The second parameter is the name of the table that will be created in the DataSet  Its purpose is to identify the table with a meaningful name later on. Typically, same name as the database table is taken. However, if the SqlDataAdapter’s select command contains a join, need to find another meaningful name. DataSet Class - Example http://www.ifourtechnolab.com/ ASP.NET Software Development Companies India
  • 21.  The architecture of ADO.net, in which connection must be opened to access the data retrieved from database is called as connected architecture  Built on the classes connection, command, datareader and transaction  This creates more traffic to the database but is normally much faster for doing smaller transactions  Example: Introduction to ADO.NET : Connected architecture Database Web Form http://www.ifourtechnolab.com/ ASP.NET Software Development Companies India
  • 22.  The architecture of ADO.net in which data retrieved from database can be accessed even when connection to database was closed is called as disconnected architecture  Built on classes connection, dataadapter, commandbuilder and dataset and dataview  Method of retrieving a record set from the database and storing it giving the ability to do many CRUD (Create, Read, Update and Delete) operations on the data in memory, then it can be re- synchronized with the database when reconnecting  Example: Introduction to ADO.NET : Disconnected architecture Database Web Form Data Adapter http://www.ifourtechnolab.com/ ASP.NET Software Development Companies India
  • 23.  A layer is a reusable portion of code that performs a specific function  This specific layer is in charge of working with other layers to perform some specific goal  Data Layer  It contains methods that helps the Business Layer to connect the data and perform required actions, whether to return data or to manipulate data (insert, update, delete)  Business Layer  A BAL contains business logic, validations or calculations related to the data. Though a website could talk to the data access layer directly, it usually goes through another layer called the Business Layer.  This ensures the data input is correct before proceeding, and can often ensure that the outputs are correct as well  Presentation Layer  Contains pages like .aspx or Windows Forms where data is presented to the user or input is taken from the user.  The ASP.NET website or Windows Forms application (the UI for the project) is called the Presentation Layer. This is the most important layer simply because it’s the one that everyone sees and uses  Even with a well structured business and data layer, if the Presentation Layer is designed poorly, this gives the users a poor view of the system Introduction to ADO.NET : 3-Tier Architecture http://www.ifourtechnolab.com/ ASP.NET Software Development Companies India
  • 24. Graphical representation of 3-Tier Architecture Introduction to ADO.NET : 3-Tier Architecture Example UI Asp.net MVC E.g.: a=20; B=10; Store c; BLL C#.net E.g.: c=a+b; DAL ADO.NET E.g.: Output c; Database E.g.: Ms Sqlserver Presentation Layer also called User Interface. Computer, Mobile phone,etc. Business Logic Layer Does all the logic operations Data Access Layer Communicate with the database http://www.ifourtechnolab.com/ ASP.NET Software Development Companies India
  • 25.  https://www.tutorialspoint.com/asp.net/asp.net_ado_net.htm  https://msdn.microsoft.com/en-us/library/27y4ybxw(v=vs.110).aspx  http://csharp-station.com/Tutorial/AdoDotNet  https://msdn.microsoft.com/en-us/library/h43ks021(v=vs.110).aspx References http://www.ifourtechnolab.com/ ASP.NET Software Development Companies India

Editor's Notes

  • #2: Software Outsourcing Company India - http://www.ifourtechnolab.com/
  • #4: Software Outsourcing Company India - http://www.ifourtechnolab.com/
  • #5: Software Outsourcing Company India - http://www.ifourtechnolab.com/
  • #6: Software Outsourcing Company India - http://www.ifourtechnolab.com/
  • #7: Software Outsourcing Company India - http://www.ifourtechnolab.com/
  • #8: Software Outsourcing Company India - http://www.ifourtechnolab.com/
  • #9: Software Outsourcing Company India - http://www.ifourtechnolab.com/
  • #10: Software Outsourcing Company India - http://www.ifourtechnolab.com/
  • #11: Software Outsourcing Company India - http://www.ifourtechnolab.com/
  • #12: Software Outsourcing Company India - http://www.ifourtechnolab.com/
  • #13: Software Outsourcing Company India - http://www.ifourtechnolab.com/
  • #14: Software Outsourcing Company India - http://www.ifourtechnolab.com/
  • #15: Software Outsourcing Company India - http://www.ifourtechnolab.com/
  • #16: Software Outsourcing Company India - http://www.ifourtechnolab.com/
  • #17: Software Outsourcing Company India - http://www.ifourtechnolab.com/
  • #18: Software Outsourcing Company India - http://www.ifourtechnolab.com/
  • #19: Software Outsourcing Company India - http://www.ifourtechnolab.com/
  • #20: Software Outsourcing Company India - http://www.ifourtechnolab.com/
  • #21: Software Outsourcing Company India - http://www.ifourtechnolab.com/
  • #22: Software Outsourcing Company India - http://www.ifourtechnolab.com/
  • #23: Software Outsourcing Company India - http://www.ifourtechnolab.com/
  • #24: Software Outsourcing Company India - http://www.ifourtechnolab.com/
  • #25: Software Outsourcing Company India - http://www.ifourtechnolab.com/
  • #26: Software Outsourcing Company India - http://www.ifourtechnolab.com/
  • #27: Software Outsourcing Company India - http://www.ifourtechnolab.com/