SlideShare a Scribd company logo
ADO.NET
Session-11-12
Objectives
• ADO versus ADO.NET
• ADO.NET Architecture
• Connection Object
• Command Object
• DataReader Object
• DataAdapter Object
• DataSet Object
• DataView Object
• Use ADO.NET to access data in an application
ADO versus ADO.NET
Feature ADO ADO.NET
Primary Aim Client/server coupled Disconnected collection of
data from data server
Form of data in memory Uses RECORDSET object
(contains one table)
Uses DATASET object
(contains one or more
DATATABLE objects)
Disconnected access Uses CONNECTION object
and RECORDSET object
with OLEDB
Uses DATASETCOMMAND
object with OLEDB
XML capabilities XML aware XML is the native transfer
medium for the objects
Code Coupled to the language
used, various
implementation
Managed code library –
Uses Common Language
Runtime, therefore,
language agnostic
 Although classic ADO was geared for a two - tiered
environment (client - server), ADO.NET addresses a
multi - tiered environment.
 ADO.NET offers many advanced features and many
different ways to retrieve your data and manipulate it
before presenting it to the end user.
 ADO.NET addresses a couple of the most common
data - access strategies that are used for
applications today
ADO.NET Architecture
ADO.NET Namespaces
• System.data :Core namespace, defines types that
represent data
• System.Data.Common:Types shared between
managed providers
• System.Data.OleDb:Types that allow connection to
OLE DB compliant data sources
• System.Data.SqlClient:Types that are optimized to
connect to Microsoft® SQL Server
• System.Data.SqlTypes:Native data types in
Microsoft® SQL Server
Needed to build a data access
application
• For OLE DB:
using System.Data
using System.Data.OleDB
• For SQL Server:
using System.Data
using System.Data.SQLClient
Connection Object
• Two provider-specific classes
SqlConnection
OleDbConnection.
This information is provided via a single string
called a connection string.
You can also store this connection string in the
web.config file of your application.
 The OLEDbConnection object, which can provide
connection to a wide range of database types like
Microsoft Access and Oracle.
 The Connection object contains all of the information
required to open a connection to the database
 With ASP.NET , you will find that there is an easy
way to manage the storage of your connection strings
using the web.config file.
 This is actually a better way to store your connection
strings rather than hard-coding them within the code
of the application itself.
• To define your connection string within the
web.config file, you are going to make use of the
<connectionStrings> section. Within this section, you
can place an <add> element to define your
connection.
• What is Web.Config File?
• Web.config file, as it sounds like is a configuration
file for the Asp .net web application. An Asp .net
application has one web.config file which keeps the
configurations required for the corresponding
application. Web.config file is written in
XML(eXtensible Markup Language) with specific
tags having specific meanings.
• <connectionStrings>
• <add name="FirstSample" connectionString="Data
Source=SANDIP;Initial Catalog=siliguri;Persist Security
Info=True;
• User ID=sa;Pwd=secret;MultipleActiveResultSets=
• False;Packet Size=4096;Application
Name=&quot;Microsoft SQL Server Management
Studio&quot;"
• providerName="System.Data.SqlClient" />
• </connectionStrings>
• <appSettings>
• <add key="FirstSample"
value="server=SANDIP;uid=sa;pwd=secret;database=sili
guri"/>
• </appSettings>
Command object
• The Command object uses the Connection object to
execute SQL queries.
• These queries can be in the form of inline text, stored
procedures, or direct table access.
• The Command object provides a number of Execute
methods that you can use to perform various types of
SQL queries.
Property description
CommandText This read/write property allows you to set or retrieve either
the T-SQL statement or the name of the stored procedure.
CommandTimeout This read/write property gets or sets the number of seconds
to wait while attempting to execute a particular command.
The command is aborted after it times out and an exception
is thrown. The default time allotted for this operation is 30
seconds.
CommandType This read/write property indicates the way the
CommandText property should be interpreted. The possible
values are StoredProcedure, TableDirect, and Text.The
value of Text means that your SQL statement is inline or
contained within the code itself.
Connection This read/write property gets or sets the SqlConnection
object that should be used
by this Command object.
Various Execute methods that can be called from a
Command object.
Property Description
ExecuteNonQuery This method executes the command specified and
returns the number of rows affected.
ExecuteReader This method executes the command specified and
returns an instance of the SqlDataReader class. The
DataReader object is a read-only and forward-only
cursor.
ExecuteRow This method executes the command and returns an
instance of the SqlRecord class. This object
contains only a single returned row.
ExecuteScalar This method executes the command specified and
returns the first column of the first row in the form
of a generic object. The remaining rows and
columns are ignored.
DataReader Object
• The DataReader object is a simple forward-only and
read-only cursor.
• Provides methods and properties that deliver a
forward-only stream of data rows from a data source
• When a DataReader is used, parts of the ADO.NET
model are cut out, providing faster and more efficient
data access
• It requires a live connection with the data source and
provides a very efficient way of looping and
consuming all or part of the result set.
 When using a DataReader object, be sure to close the
connection when you are done using the data reader.
 If not, then the connection stays alive.
 The connection utilized stays alive until it is
explicitly closed using the Close() method or until
you have enabled your Command object to close the
connection.
 Data Reader is returned as the result of the Command
objects,s ExecuteReader method.
void Page_Load(Object sender, EventArgs e)
{
SqlConnection myConnection;
SqlCommand myCommand;
SqlDataReader myDataReader;
myConnection = new
SqlConnection(ConfigurationSettings.AppSettings["strConn"]
); myConnection.Open();
//prepare sql statements
myCommand = new SqlCommand("SELECT TOP 10 * FROM
EMPLOYEE", myConnection);
myDataReader = myCommand.ExecuteReader();
while (myDataReader.Read())
{
Response.Write(myDataReader["fname"]);
//Spacing
Response.Write(" ");
Response.Write(myDataReader["minit"]);
//Spacing
Response.Write(" ");
Response.Write(myDataReader["lname"]);
//New Line
Response.Write("<br>");
}
//cleanup objects
myDataReader.Close();
myConnection.Close();
}
DataAdapter Object
• The SqlDataAdapter is a special class whose purpose
is to bridge the gap between the disconnected
DataTable objects and the physical data source.
• Provides a set of methods and properties to retrieve
and save data between a DataSet and its source data
store
• Allows the use of stored procedures Connects to the
database to fill the DataSet and also update the
database
• It is capable of executing a SELECT statement on a
data source and transferring the result set into a
DataTable object.
It is also capable of executing the standard INSERT,
UPDATE, and DELETE statements and extracting
the input data from a DataTable object.
The SqlDataAdapter class also provides a method
called Fill().
Summaries
• ADO.NET architecture.
• Several classes on ADO.NET.
• Web Config.

More Related Content

What's hot

Dbms relational model
Dbms relational modelDbms relational model
Dbms relational model
Chirag vasava
 
Schema
SchemaSchema
Relational model
Relational modelRelational model
Relational model
Dabbal Singh Mahara
 
Data warehouse and data mining
Data warehouse and data miningData warehouse and data mining
Data warehouse and data mining
Pradnya Saval
 
Relational Data Model Introduction
Relational Data Model IntroductionRelational Data Model Introduction
Relational Data Model Introduction
Nishant Munjal
 
Dbms 14: Relational Calculus
Dbms 14: Relational CalculusDbms 14: Relational Calculus
Dbms 14: Relational Calculus
Amiya9439793168
 
Degree of relationship set
Degree of relationship setDegree of relationship set
Degree of relationship set
Megha Sharma
 
Data Integration and Transformation in Data mining
Data Integration and Transformation in Data miningData Integration and Transformation in Data mining
Data Integration and Transformation in Data mining
kavitha muneeshwaran
 
Data integration
Data integrationData integration
Data integration
kalavathisugan
 
behavioral model (DFD & state diagram)
behavioral model (DFD & state diagram)behavioral model (DFD & state diagram)
behavioral model (DFD & state diagram)
Lokesh Singrol
 
Structure of dbms
Structure of dbmsStructure of dbms
Structure of dbms
Megha yadav
 
Data mining
Data miningData mining
Data mining
nandini patil
 
Database language
Database languageDatabase language
Chapter 3: ado.net
Chapter 3: ado.netChapter 3: ado.net
Chapter 3: ado.net
Ngeam Soly
 
Distributed database management system
Distributed database management systemDistributed database management system
Distributed database management system
Vinay D. Patel
 
Introduction to database
Introduction to databaseIntroduction to database
Introduction to database
Arpee Callejo
 
Advance database systems (part 1)
Advance database systems (part 1)Advance database systems (part 1)
Advance database systems (part 1)
Abdullah Khosa
 
DBMS Notes: DDL DML DCL
DBMS Notes: DDL DML DCLDBMS Notes: DDL DML DCL
DBMS Notes: DDL DML DCL
Sreedhar Chowdam
 
Introduction To Data Mining
Introduction To Data Mining   Introduction To Data Mining
Introduction To Data Mining Phi Jack
 

What's hot (20)

Dbms relational model
Dbms relational modelDbms relational model
Dbms relational model
 
Schema
SchemaSchema
Schema
 
Relational model
Relational modelRelational model
Relational model
 
Sql select
Sql select Sql select
Sql select
 
Data warehouse and data mining
Data warehouse and data miningData warehouse and data mining
Data warehouse and data mining
 
Relational Data Model Introduction
Relational Data Model IntroductionRelational Data Model Introduction
Relational Data Model Introduction
 
Dbms 14: Relational Calculus
Dbms 14: Relational CalculusDbms 14: Relational Calculus
Dbms 14: Relational Calculus
 
Degree of relationship set
Degree of relationship setDegree of relationship set
Degree of relationship set
 
Data Integration and Transformation in Data mining
Data Integration and Transformation in Data miningData Integration and Transformation in Data mining
Data Integration and Transformation in Data mining
 
Data integration
Data integrationData integration
Data integration
 
behavioral model (DFD & state diagram)
behavioral model (DFD & state diagram)behavioral model (DFD & state diagram)
behavioral model (DFD & state diagram)
 
Structure of dbms
Structure of dbmsStructure of dbms
Structure of dbms
 
Data mining
Data miningData mining
Data mining
 
Database language
Database languageDatabase language
Database language
 
Chapter 3: ado.net
Chapter 3: ado.netChapter 3: ado.net
Chapter 3: ado.net
 
Distributed database management system
Distributed database management systemDistributed database management system
Distributed database management system
 
Introduction to database
Introduction to databaseIntroduction to database
Introduction to database
 
Advance database systems (part 1)
Advance database systems (part 1)Advance database systems (part 1)
Advance database systems (part 1)
 
DBMS Notes: DDL DML DCL
DBMS Notes: DDL DML DCLDBMS Notes: DDL DML DCL
DBMS Notes: DDL DML DCL
 
Introduction To Data Mining
Introduction To Data Mining   Introduction To Data Mining
Introduction To Data Mining
 

Similar to ASP.NET Session 11 12

ADO.NET by ASP.NET Development Company in india
ADO.NET by ASP.NET  Development Company in indiaADO.NET by ASP.NET  Development Company in india
ADO.NET by ASP.NET Development Company in india
iFour Institute - Sustainable Learning
 
Chap14 ado.net
Chap14 ado.netChap14 ado.net
Chap14 ado.net
mentorrbuddy
 
Ch06 ado.net fundamentals
Ch06 ado.net fundamentalsCh06 ado.net fundamentals
Ch06 ado.net fundamentalsMadhuri Kavade
 
Ado.Net Architecture
Ado.Net ArchitectureAdo.Net Architecture
Ado.Net Architecture
Umar Farooq
 
Lecture 6. ADO.NET Overview.
Lecture 6. ADO.NET Overview.Lecture 6. ADO.NET Overview.
Lecture 6. ADO.NET Overview.
Alexey Furmanov
 
Introduction to ado
Introduction to adoIntroduction to ado
Introduction to adoHarman Bajwa
 
ASP.Net Presentation Part2
ASP.Net Presentation Part2ASP.Net Presentation Part2
ASP.Net Presentation Part2Neeraj Mathur
 
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
facebookrecovery1
 
Ado
AdoAdo
Marmagna desai
Marmagna desaiMarmagna desai
Marmagna desai
jmsthakur
 
LECTURE 14 Data Access.pptx
LECTURE 14 Data Access.pptxLECTURE 14 Data Access.pptx
LECTURE 14 Data Access.pptx
AOmaAli
 
Asp .Net Database Connectivity Presentation.pptx
Asp .Net Database Connectivity Presentation.pptxAsp .Net Database Connectivity Presentation.pptx
Asp .Net Database Connectivity Presentation.pptx
sridharu1981
 
Advance Java Practical file
Advance Java Practical fileAdvance Java Practical file
Advance Java Practical file
varun arora
 
For Beginers - ADO.Net
For Beginers - ADO.NetFor Beginers - ADO.Net
For Beginers - ADO.Net
Snehal Harawande
 
unit 3.docx
unit 3.docxunit 3.docx
unit 3.docx
Sadhana Sreekanth
 

Similar to ASP.NET Session 11 12 (20)

Ado.net
Ado.netAdo.net
Ado.net
 
ADO.NET by ASP.NET Development Company in india
ADO.NET by ASP.NET  Development Company in indiaADO.NET by ASP.NET  Development Company in india
ADO.NET by ASP.NET Development Company in india
 
Ado.net
Ado.netAdo.net
Ado.net
 
Chap14 ado.net
Chap14 ado.netChap14 ado.net
Chap14 ado.net
 
Ado
AdoAdo
Ado
 
Ch06 ado.net fundamentals
Ch06 ado.net fundamentalsCh06 ado.net fundamentals
Ch06 ado.net fundamentals
 
Ado.Net Architecture
Ado.Net ArchitectureAdo.Net Architecture
Ado.Net Architecture
 
Lecture 6. ADO.NET Overview.
Lecture 6. ADO.NET Overview.Lecture 6. ADO.NET Overview.
Lecture 6. ADO.NET Overview.
 
Introduction to ado
Introduction to adoIntroduction to ado
Introduction to ado
 
ASP.Net Presentation Part2
ASP.Net Presentation Part2ASP.Net Presentation Part2
ASP.Net Presentation Part2
 
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
 
Unit4
Unit4Unit4
Unit4
 
Ado
AdoAdo
Ado
 
Marmagna desai
Marmagna desaiMarmagna desai
Marmagna desai
 
LECTURE 14 Data Access.pptx
LECTURE 14 Data Access.pptxLECTURE 14 Data Access.pptx
LECTURE 14 Data Access.pptx
 
Asp .Net Database Connectivity Presentation.pptx
Asp .Net Database Connectivity Presentation.pptxAsp .Net Database Connectivity Presentation.pptx
Asp .Net Database Connectivity Presentation.pptx
 
Advance Java Practical file
Advance Java Practical fileAdvance Java Practical file
Advance Java Practical file
 
PPT temp.pptx
PPT temp.pptxPPT temp.pptx
PPT temp.pptx
 
For Beginers - ADO.Net
For Beginers - ADO.NetFor Beginers - ADO.Net
For Beginers - ADO.Net
 
unit 3.docx
unit 3.docxunit 3.docx
unit 3.docx
 

More from Sisir Ghosh

ASP.NET Session 2
ASP.NET Session 2ASP.NET Session 2
ASP.NET Session 2Sisir Ghosh
 
ASP.NET Session 3
ASP.NET Session 3ASP.NET Session 3
ASP.NET Session 3Sisir Ghosh
 
ASP.NET Session 4
ASP.NET Session 4ASP.NET Session 4
ASP.NET Session 4Sisir Ghosh
 
ASP.NET Session 5
ASP.NET Session 5ASP.NET Session 5
ASP.NET Session 5Sisir Ghosh
 
ASP.NET Session 6
ASP.NET Session 6ASP.NET Session 6
ASP.NET Session 6Sisir Ghosh
 
ASP.NET Session 7
ASP.NET Session 7ASP.NET Session 7
ASP.NET Session 7Sisir Ghosh
 
ASP.NET Session 8
ASP.NET Session 8ASP.NET Session 8
ASP.NET Session 8Sisir Ghosh
 
ASP.NET Session 9
ASP.NET Session 9ASP.NET Session 9
ASP.NET Session 9Sisir Ghosh
 
ASP.NET Session 10
ASP.NET Session 10ASP.NET Session 10
ASP.NET Session 10Sisir Ghosh
 
ASP.NET Session 13 14
ASP.NET Session 13 14ASP.NET Session 13 14
ASP.NET Session 13 14Sisir Ghosh
 
ASP.NET Session 16
ASP.NET Session 16ASP.NET Session 16
ASP.NET Session 16Sisir Ghosh
 
ASP.NET System design 2
ASP.NET System design 2ASP.NET System design 2
ASP.NET System design 2Sisir Ghosh
 
ASP.NET Session 1
ASP.NET Session 1ASP.NET Session 1
ASP.NET Session 1Sisir Ghosh
 
Network security
Network securityNetwork security
Network securitySisir Ghosh
 
Module ii physical layer
Module ii physical layerModule ii physical layer
Module ii physical layerSisir Ghosh
 
Error detection and correction
Error detection and correctionError detection and correction
Error detection and correctionSisir Ghosh
 
Overview of data communication and networking
Overview of data communication and networkingOverview of data communication and networking
Overview of data communication and networkingSisir Ghosh
 
Application layer
Application layerApplication layer
Application layerSisir Ghosh
 

More from Sisir Ghosh (20)

ASP.NET Session 2
ASP.NET Session 2ASP.NET Session 2
ASP.NET Session 2
 
ASP.NET Session 3
ASP.NET Session 3ASP.NET Session 3
ASP.NET Session 3
 
ASP.NET Session 4
ASP.NET Session 4ASP.NET Session 4
ASP.NET Session 4
 
ASP.NET Session 5
ASP.NET Session 5ASP.NET Session 5
ASP.NET Session 5
 
ASP.NET Session 6
ASP.NET Session 6ASP.NET Session 6
ASP.NET Session 6
 
ASP.NET Session 7
ASP.NET Session 7ASP.NET Session 7
ASP.NET Session 7
 
ASP.NET Session 8
ASP.NET Session 8ASP.NET Session 8
ASP.NET Session 8
 
ASP.NET Session 9
ASP.NET Session 9ASP.NET Session 9
ASP.NET Session 9
 
ASP.NET Session 10
ASP.NET Session 10ASP.NET Session 10
ASP.NET Session 10
 
ASP.NET Session 13 14
ASP.NET Session 13 14ASP.NET Session 13 14
ASP.NET Session 13 14
 
ASP.NET Session 16
ASP.NET Session 16ASP.NET Session 16
ASP.NET Session 16
 
ASP.NET System design 2
ASP.NET System design 2ASP.NET System design 2
ASP.NET System design 2
 
ASP.NET Session 1
ASP.NET Session 1ASP.NET Session 1
ASP.NET Session 1
 
Transport layer
Transport layerTransport layer
Transport layer
 
Routing
RoutingRouting
Routing
 
Network security
Network securityNetwork security
Network security
 
Module ii physical layer
Module ii physical layerModule ii physical layer
Module ii physical layer
 
Error detection and correction
Error detection and correctionError detection and correction
Error detection and correction
 
Overview of data communication and networking
Overview of data communication and networkingOverview of data communication and networking
Overview of data communication and networking
 
Application layer
Application layerApplication layer
Application layer
 

Recently uploaded

PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
Ralf Eggert
 
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...
Product School
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
CatarinaPereira64715
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
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...
Jeffrey Haguewood
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
Product School
 
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
Tobias Schneck
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Product School
 
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...
Product School
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 

Recently uploaded (20)

PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 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...
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
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 for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
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
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
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...
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 

ASP.NET Session 11 12

  • 2. Objectives • ADO versus ADO.NET • ADO.NET Architecture • Connection Object • Command Object • DataReader Object • DataAdapter Object • DataSet Object • DataView Object • Use ADO.NET to access data in an application
  • 3. ADO versus ADO.NET Feature ADO ADO.NET Primary Aim Client/server coupled Disconnected collection of data from data server Form of data in memory Uses RECORDSET object (contains one table) Uses DATASET object (contains one or more DATATABLE objects) Disconnected access Uses CONNECTION object and RECORDSET object with OLEDB Uses DATASETCOMMAND object with OLEDB XML capabilities XML aware XML is the native transfer medium for the objects Code Coupled to the language used, various implementation Managed code library – Uses Common Language Runtime, therefore, language agnostic
  • 4.  Although classic ADO was geared for a two - tiered environment (client - server), ADO.NET addresses a multi - tiered environment.  ADO.NET offers many advanced features and many different ways to retrieve your data and manipulate it before presenting it to the end user.  ADO.NET addresses a couple of the most common data - access strategies that are used for applications today
  • 6. ADO.NET Namespaces • System.data :Core namespace, defines types that represent data • System.Data.Common:Types shared between managed providers • System.Data.OleDb:Types that allow connection to OLE DB compliant data sources • System.Data.SqlClient:Types that are optimized to connect to Microsoft® SQL Server • System.Data.SqlTypes:Native data types in Microsoft® SQL Server
  • 7. Needed to build a data access application • For OLE DB: using System.Data using System.Data.OleDB • For SQL Server: using System.Data using System.Data.SQLClient
  • 8. Connection Object • Two provider-specific classes SqlConnection OleDbConnection. This information is provided via a single string called a connection string. You can also store this connection string in the web.config file of your application.
  • 9.  The OLEDbConnection object, which can provide connection to a wide range of database types like Microsoft Access and Oracle.  The Connection object contains all of the information required to open a connection to the database  With ASP.NET , you will find that there is an easy way to manage the storage of your connection strings using the web.config file.  This is actually a better way to store your connection strings rather than hard-coding them within the code of the application itself.
  • 10. • To define your connection string within the web.config file, you are going to make use of the <connectionStrings> section. Within this section, you can place an <add> element to define your connection. • What is Web.Config File? • Web.config file, as it sounds like is a configuration file for the Asp .net web application. An Asp .net application has one web.config file which keeps the configurations required for the corresponding application. Web.config file is written in XML(eXtensible Markup Language) with specific tags having specific meanings.
  • 11. • <connectionStrings> • <add name="FirstSample" connectionString="Data Source=SANDIP;Initial Catalog=siliguri;Persist Security Info=True; • User ID=sa;Pwd=secret;MultipleActiveResultSets= • False;Packet Size=4096;Application Name=&quot;Microsoft SQL Server Management Studio&quot;" • providerName="System.Data.SqlClient" /> • </connectionStrings> • <appSettings> • <add key="FirstSample" value="server=SANDIP;uid=sa;pwd=secret;database=sili guri"/> • </appSettings>
  • 12. Command object • The Command object uses the Connection object to execute SQL queries. • These queries can be in the form of inline text, stored procedures, or direct table access. • The Command object provides a number of Execute methods that you can use to perform various types of SQL queries.
  • 13. Property description CommandText This read/write property allows you to set or retrieve either the T-SQL statement or the name of the stored procedure. CommandTimeout This read/write property gets or sets the number of seconds to wait while attempting to execute a particular command. The command is aborted after it times out and an exception is thrown. The default time allotted for this operation is 30 seconds. CommandType This read/write property indicates the way the CommandText property should be interpreted. The possible values are StoredProcedure, TableDirect, and Text.The value of Text means that your SQL statement is inline or contained within the code itself. Connection This read/write property gets or sets the SqlConnection object that should be used by this Command object.
  • 14. Various Execute methods that can be called from a Command object. Property Description ExecuteNonQuery This method executes the command specified and returns the number of rows affected. ExecuteReader This method executes the command specified and returns an instance of the SqlDataReader class. The DataReader object is a read-only and forward-only cursor. ExecuteRow This method executes the command and returns an instance of the SqlRecord class. This object contains only a single returned row. ExecuteScalar This method executes the command specified and returns the first column of the first row in the form of a generic object. The remaining rows and columns are ignored.
  • 15. DataReader Object • The DataReader object is a simple forward-only and read-only cursor. • Provides methods and properties that deliver a forward-only stream of data rows from a data source • When a DataReader is used, parts of the ADO.NET model are cut out, providing faster and more efficient data access • It requires a live connection with the data source and provides a very efficient way of looping and consuming all or part of the result set.
  • 16.  When using a DataReader object, be sure to close the connection when you are done using the data reader.  If not, then the connection stays alive.  The connection utilized stays alive until it is explicitly closed using the Close() method or until you have enabled your Command object to close the connection.  Data Reader is returned as the result of the Command objects,s ExecuteReader method.
  • 17. void Page_Load(Object sender, EventArgs e) { SqlConnection myConnection; SqlCommand myCommand; SqlDataReader myDataReader; myConnection = new SqlConnection(ConfigurationSettings.AppSettings["strConn"] ); myConnection.Open(); //prepare sql statements myCommand = new SqlCommand("SELECT TOP 10 * FROM EMPLOYEE", myConnection); myDataReader = myCommand.ExecuteReader(); while (myDataReader.Read()) { Response.Write(myDataReader["fname"]);
  • 18. //Spacing Response.Write(" "); Response.Write(myDataReader["minit"]); //Spacing Response.Write(" "); Response.Write(myDataReader["lname"]); //New Line Response.Write("<br>"); } //cleanup objects myDataReader.Close(); myConnection.Close(); }
  • 19. DataAdapter Object • The SqlDataAdapter is a special class whose purpose is to bridge the gap between the disconnected DataTable objects and the physical data source. • Provides a set of methods and properties to retrieve and save data between a DataSet and its source data store • Allows the use of stored procedures Connects to the database to fill the DataSet and also update the database • It is capable of executing a SELECT statement on a data source and transferring the result set into a DataTable object.
  • 20. It is also capable of executing the standard INSERT, UPDATE, and DELETE statements and extracting the input data from a DataTable object. The SqlDataAdapter class also provides a method called Fill().
  • 21. Summaries • ADO.NET architecture. • Several classes on ADO.NET. • Web Config.