SlideShare a Scribd company logo
3
Most read
5
Most read
10
Most read
WELCOME
TO
ASP.NET Tutorials
on
Data Sources
• A data source control interacts with the data-bound controls and hides the complex
data binding processes. These are the tools that provide data to the data bound
controls and support execution of operations like insertions, deletions, sorting, and
updates.
• Each data source control wraps a particular data provider-relational databases, XML
documents, or custom classes and helps in:
• Managing connection
• Selecting data
• Managing presentation aspects like paging, caching, etc.
• Manipulating data
• There are many data source controls available in ASP.NET for accessing data from SQL
Server, from ODBC or OLE DB servers, from XML files, and from business objects.
• Based on type of data, these controls could be divided into two
categories:
• Hierarchical data source controls
• Table-based data source controls
• The data source controls used for hierarchical data are:
• XMLDataSource - It allows binding to XML files and strings with
or without schema information.
• SiteMapDataSource - It allows binding to a provider that supplies
site map information.
Data source controls Description
SqlDataSource It represents a connection to an ADO.NET data provider that
returns SQL data, including data sources accessible via
OLEDB and QDBC.
ObjectDataSource It allows binding to a custom .Net business object that
returns data.
LinqdataSource It allows binding to the results of a Linq-to-SQL query
(supported by ASP.NET 3.5 only).
AccessDataSource It represents connection to a Microsoft Access database.
Data Source Views
• Data source views are objects of the DataSourceView class.
Which represent a customized view of data for different
data operations such as sorting, filtering, etc.
• The DataSourceView class serves as the base class for all
data source view classes, which define the capabilities of
data source controls.
Properties Description
CanDelete Indicates whether deletion is allowed on the underlying data source.
CanInsert Indicates whether insertion is allowed on the underlying data source.
CanPage Indicates whether paging is allowed on the underlying data source.
CanRetrieveTotalRowCount Indicates whether total row count information is available.
CanSort Indicates whether the data could be sorted.
CanUpdate Indicates whether updates are allowed on the underlying data source.
Events Gets a list of event-handler delegates for the data source view.
Name Name of the view.
Methods Description
CanExecute Determines whether the specified command can be executed.
ExecuteCommand Executes the specific command.
ExecuteDelete Performs a delete operation on the list of data that the DataSourceView
object represents.
ExecuteInsert Performs an insert operation on the list of data that the DataSourceView
object represents.
ExecuteSelect Gets a list of data from the underlying data storage.
ExecuteUpdate Performs an update operation on the list of data that the DataSourceView object
represents.
Delete Performs a delete operation on the data associated with the view.
Insert Performs an insert operation on the data associated with the view.
Select Returns the queried data.
Update Performs an update operation on the data associated with the view.
OnDataSourceView
Changed
Raises the DataSourceViewChanged event.
RaiseUnsupported
CapabilitiesError
Called by the RaiseUnsupportedCapabilitiesError method to compare the capabilities
requested for an ExecuteSelect operation against those that the view supports.
The SqlDataSource Control
• The SqlDataSource control represents a connection to a relational database
such as SQL Server or Oracle database, or data accessible through OLEDB or
Open Database Connectivity (ODBC). Connection to data is made through two
important properties ConnectionString and ProviderName.
• The following code snippet provides the basic syntax of the control:
• <asp:SqlDataSource runat="server" ID="MySqlSource" ProviderName='<%$
ConnectionStrings:LocalNWind.ProviderName %>' ConnectionString='<%$
ConnectionStrings:LocalNWind %>' SelectionCommand= "SELECT * FROM
EMPLOYEES" /> <asp:GridView ID="GridView1" runat="server"
DataSourceID="MySqlSource" />
• Configuring various data operations on the underlying data depends upon the
various properties (property groups) of the data source control.
Property Group Description
DeleteCommand,
DeleteParameters,
DeleteCommandType
Gets or sets the SQL statement, parameters, and type for
deleting rows in the underlying data.
FilterExpression,
FilterParameters
Gets or sets the data filtering string and parameters.
InsertCommand,
InsertParameters,
InsertCommandType
Gets or sets the SQL statement, parameters, and type for
inserting rows in the underlying database.
SelectCommand,
SelectParameters,
SelectCommandType
Gets or sets the SQL statement, parameters, and type for retrieving
rows from the underlying database.
SortParameterName Gets or sets the name of an input parameter that the command's
stored procedure will use to sort data.
UpdateCommand,
UpdateParameters,
UpdateCommandType
Gets or sets the SQL statement, parameters, and type for updating
rows in the underlying data store.
The ObjectDataSource Control
• The ObjectDataSource Control enables user-defined classes to associate the
output of their methods to data bound controls. The programming interface
of this class is almost same as the SqlDataSource control.
• Following are two important aspects of binding business objects:
• The bindable class should have a default constructor, it should be stateless,
and have methods that can be mapped to select, update, insert, and delete
semantics.
• The object must update one item at a time, batch operations are not
supported.
• Let us go directly to an example to work with this control. The student class is
the class to be used with an object data source. This class has three
properties: a student id, name, and city. It has a default constructor and a
GetStudents method for retrieving data.
The AccessDataSource Control
• The AccessDataSource control represents a connection to an Access database. It is
based on the SqlDataSource control and provides simpler programming interface.
The following code snippet provides the basic syntax for the data source:
• <asp:AccessDataSource ID="AccessDataSource1 runat="server"
DataFile="~/App_Data/ASPDotNetStepByStep.mdb" SelectCommand="SELECT *
FROM [DotNetReferences]"> </asp:AccessDataSource>
• The AccessDataSource control opens the database in read-only mode. However, it
can also be used for performing insert, update, or delete operations. This is done
using the ADO.NET commands and parameter collection.
• Updates are problematic for Access databases from within an ASP.NET application
because an Access database is a plain file and the default account of the ASP.NET
application might not have the permission to write to the database file.
Thank You
For more updates on C#, ASP.NET, MVC, JAVASCRIPT, HTML,
CSS tutorials subscribe to our YouTube channel
SIRYMEDIA
Visit our website for more
www.sirymedia.in

More Related Content

What's hot (20)

PPTX
File allocation methods (1)
Dr. Jasmine Beulah Gnanadurai
 
PPT
Coupling and cohesion
Sutha31
 
PPTX
Cohesion and coupling
Aprajita (Abbey) Singh
 
PPT
Introduction to Google App Engine
rajdeep
 
PPTX
C# Framework class library
Prem Kumar Badri
 
PPT
Swap-space Management
Agnas Jasmine
 
DOCX
Food donation project report II
Dhananjaysinh Jhala
 
PDF
Php array
Nikul Shah
 
PDF
JavaScript - Chapter 13 - Browser Object Model(BOM)
WebStackAcademy
 
PPT
Visual programming lecture
AqsaHayat3
 
PPT
Unit 2(advanced class modeling & state diagram)
Manoj Reddy
 
PDF
User Interface Design- Module 3 Menus
brindaN
 
PDF
Bootstrap
Jadson Santos
 
PPTX
Password management
Sai Kumar
 
PPTX
SQL, Embedded SQL, Dynamic SQL and SQLJ
Dharita Chokshi
 
PPTX
Dynamic storage allocation techniques in Compiler design
kunjan shah
 
PPTX
E book management system
Barani Tharan
 
PPSX
Javascript variables and datatypes
Varun C M
 
PPTX
Java Server Pages(jsp)
Manisha Keim
 
PPTX
I/O Management
Keyur Vadodariya
 
File allocation methods (1)
Dr. Jasmine Beulah Gnanadurai
 
Coupling and cohesion
Sutha31
 
Cohesion and coupling
Aprajita (Abbey) Singh
 
Introduction to Google App Engine
rajdeep
 
C# Framework class library
Prem Kumar Badri
 
Swap-space Management
Agnas Jasmine
 
Food donation project report II
Dhananjaysinh Jhala
 
Php array
Nikul Shah
 
JavaScript - Chapter 13 - Browser Object Model(BOM)
WebStackAcademy
 
Visual programming lecture
AqsaHayat3
 
Unit 2(advanced class modeling & state diagram)
Manoj Reddy
 
User Interface Design- Module 3 Menus
brindaN
 
Bootstrap
Jadson Santos
 
Password management
Sai Kumar
 
SQL, Embedded SQL, Dynamic SQL and SQLJ
Dharita Chokshi
 
Dynamic storage allocation techniques in Compiler design
kunjan shah
 
E book management system
Barani Tharan
 
Javascript variables and datatypes
Varun C M
 
Java Server Pages(jsp)
Manisha Keim
 
I/O Management
Keyur Vadodariya
 

Viewers also liked (13)

PDF
Refrigerios Inicial Huancavelica
Gerson Ames
 
PDF
autsourcing y emporwenmet
Andris Prieto
 
PDF
Three Little Kids
Belal Elkadri
 
PPTX
Escritorio remoto
Jesus Valenzuela
 
PDF
Rubber & Tyre Machinery World - Collectors Edition - Dec 2015
Rubber & Tyre Machinery World
 
PDF
C - Retread Procedures for Commercial Tires
Robert McElroy
 
PPT
Clase 10 SPSS
CONASIN PERU
 
PDF
Rubber calenders at a glance
Rubber & Tyre Machinery World
 
PPT
3. regimen tributario aduanero peru 1
VICTOR HUGO QUISPE CABRERA
 
PPTX
Custom control in asp.net
Sireesh K
 
PDF
The Art of Owning & Operating Rubber Calenders
Rubber & Tyre Machinery World
 
PDF
El ciclo vital de una iglesia
Pablo A. Jimenez
 
PPTX
Balance Of Power
Anas ali
 
Refrigerios Inicial Huancavelica
Gerson Ames
 
autsourcing y emporwenmet
Andris Prieto
 
Three Little Kids
Belal Elkadri
 
Escritorio remoto
Jesus Valenzuela
 
Rubber & Tyre Machinery World - Collectors Edition - Dec 2015
Rubber & Tyre Machinery World
 
C - Retread Procedures for Commercial Tires
Robert McElroy
 
Clase 10 SPSS
CONASIN PERU
 
Rubber calenders at a glance
Rubber & Tyre Machinery World
 
3. regimen tributario aduanero peru 1
VICTOR HUGO QUISPE CABRERA
 
Custom control in asp.net
Sireesh K
 
The Art of Owning & Operating Rubber Calenders
Rubber & Tyre Machinery World
 
El ciclo vital de una iglesia
Pablo A. Jimenez
 
Balance Of Power
Anas ali
 
Ad

Similar to Datasource in asp.net (20)

PPTX
Ch 7 data binding
Madhuri Kavade
 
PDF
WEB PROGRAMMING USING ASP.NET
DhruvVekariya3
 
PPTX
Chapter 15
application developer
 
DOCX
Grid view control
Paneliya Prince
 
PPSX
06 asp.net session08
Vivek Singh Chandel
 
PPS
06 asp.net session08
Mani Chaubey
 
PPT
Marmagna desai
jmsthakur
 
PPTX
Work with data in ASP.NET
Peter Gfader
 
PPT
2005 - .NET Chaostage: 1st class data driven applications with ASP.NET 2.0
Daniel Fisher
 
PPS
Vb.net session 06
Niit Care
 
PPT
the .NET Framework. It provides the claf
TesfahunMaru1
 
PPT
Lecture 6. ADO.NET Overview.
Alexey Furmanov
 
PPS
VISUAL BASIC .net data accesss vii
argusacademy
 
PPT
Introduction to ADO.NET
rchakra
 
PPTX
asp.net data controls
subakrish
 
PPTX
data controls in asp.net
subakrish
 
PDF
Database Programming With Visual Basic Net And Adonet Tips Tutorials And Code...
keeverfelmor
 
PPT
ASP.NET Session 11 12
Sisir Ghosh
 
PPT
Ado.net
Iblesoft
 
PPTX
Ado .net
Manish Singh
 
Ch 7 data binding
Madhuri Kavade
 
WEB PROGRAMMING USING ASP.NET
DhruvVekariya3
 
Grid view control
Paneliya Prince
 
06 asp.net session08
Vivek Singh Chandel
 
06 asp.net session08
Mani Chaubey
 
Marmagna desai
jmsthakur
 
Work with data in ASP.NET
Peter Gfader
 
2005 - .NET Chaostage: 1st class data driven applications with ASP.NET 2.0
Daniel Fisher
 
Vb.net session 06
Niit Care
 
the .NET Framework. It provides the claf
TesfahunMaru1
 
Lecture 6. ADO.NET Overview.
Alexey Furmanov
 
VISUAL BASIC .net data accesss vii
argusacademy
 
Introduction to ADO.NET
rchakra
 
asp.net data controls
subakrish
 
data controls in asp.net
subakrish
 
Database Programming With Visual Basic Net And Adonet Tips Tutorials And Code...
keeverfelmor
 
ASP.NET Session 11 12
Sisir Ghosh
 
Ado.net
Iblesoft
 
Ado .net
Manish Singh
 
Ad

More from Sireesh K (20)

PPTX
Cn10
Sireesh K
 
PPTX
chanakya neeti
Sireesh K
 
PPTX
chanakya neeti
Sireesh K
 
DOCX
What is mvc
Sireesh K
 
PPTX
31c
Sireesh K
 
PPTX
31cs
Sireesh K
 
PPTX
45c
Sireesh K
 
PPTX
44c
Sireesh K
 
PPTX
43c
Sireesh K
 
PPTX
42c
Sireesh K
 
PPTX
41c
Sireesh K
 
PPTX
40c
Sireesh K
 
PPTX
39c
Sireesh K
 
PPTX
38c
Sireesh K
 
PPTX
37c
Sireesh K
 
PPTX
35c
Sireesh K
 
PPTX
34c
Sireesh K
 
PPTX
33c
Sireesh K
 
PPTX
30c
Sireesh K
 
PPTX
29c
Sireesh K
 
Cn10
Sireesh K
 
chanakya neeti
Sireesh K
 
chanakya neeti
Sireesh K
 
What is mvc
Sireesh K
 
31cs
Sireesh K
 

Recently uploaded (20)

PDF
Introduction presentation of the patentbutler tool
MIPLM
 
PDF
QNL June Edition hosted by Pragya the official Quiz Club of the University of...
Pragya - UEM Kolkata Quiz Club
 
PDF
Android Programming - Basics of Mobile App, App tools and Android Basics
Kavitha P.V
 
PPTX
Identifying elements in the story. Arrange the events in the story
geraldineamahido2
 
PDF
epi editorial commitee meeting presentation
MIPLM
 
PDF
STATEMENT-BY-THE-HON.-MINISTER-FOR-HEALTH-ON-THE-COVID-19-OUTBREAK-AT-UG_revi...
nservice241
 
PDF
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
PDF
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
PPTX
Post Dated Cheque(PDC) Management in Odoo 18
Celine George
 
PPTX
How to Configure Re-Ordering From Portal in Odoo 18 Website
Celine George
 
PDF
AI-Powered-Visual-Storytelling-for-Nonprofits.pdf
TechSoup
 
PDF
Vani - The Voice of Excellence - Jul 2025 issue
Savipriya Raghavendra
 
PDF
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
PPTX
DAY 1_QUARTER1 ENGLISH 5 WEEK- PRESENTATION.pptx
BanyMacalintal
 
PPTX
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
PPTX
Difference between write and update in odoo 18
Celine George
 
PDF
Characteristics, Strengths and Weaknesses of Quantitative Research.pdf
Thelma Villaflores
 
PPTX
How to Manage Allocation Report for Manufacturing Orders in Odoo 18
Celine George
 
PDF
Knee Extensor Mechanism Injuries - Orthopedic Radiologic Imaging
Sean M. Fox
 
PDF
The Constitution Review Committee (CRC) has released an updated schedule for ...
nservice241
 
Introduction presentation of the patentbutler tool
MIPLM
 
QNL June Edition hosted by Pragya the official Quiz Club of the University of...
Pragya - UEM Kolkata Quiz Club
 
Android Programming - Basics of Mobile App, App tools and Android Basics
Kavitha P.V
 
Identifying elements in the story. Arrange the events in the story
geraldineamahido2
 
epi editorial commitee meeting presentation
MIPLM
 
STATEMENT-BY-THE-HON.-MINISTER-FOR-HEALTH-ON-THE-COVID-19-OUTBREAK-AT-UG_revi...
nservice241
 
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
Post Dated Cheque(PDC) Management in Odoo 18
Celine George
 
How to Configure Re-Ordering From Portal in Odoo 18 Website
Celine George
 
AI-Powered-Visual-Storytelling-for-Nonprofits.pdf
TechSoup
 
Vani - The Voice of Excellence - Jul 2025 issue
Savipriya Raghavendra
 
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
DAY 1_QUARTER1 ENGLISH 5 WEEK- PRESENTATION.pptx
BanyMacalintal
 
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
Difference between write and update in odoo 18
Celine George
 
Characteristics, Strengths and Weaknesses of Quantitative Research.pdf
Thelma Villaflores
 
How to Manage Allocation Report for Manufacturing Orders in Odoo 18
Celine George
 
Knee Extensor Mechanism Injuries - Orthopedic Radiologic Imaging
Sean M. Fox
 
The Constitution Review Committee (CRC) has released an updated schedule for ...
nservice241
 

Datasource in asp.net

  • 3. • A data source control interacts with the data-bound controls and hides the complex data binding processes. These are the tools that provide data to the data bound controls and support execution of operations like insertions, deletions, sorting, and updates. • Each data source control wraps a particular data provider-relational databases, XML documents, or custom classes and helps in: • Managing connection • Selecting data • Managing presentation aspects like paging, caching, etc. • Manipulating data • There are many data source controls available in ASP.NET for accessing data from SQL Server, from ODBC or OLE DB servers, from XML files, and from business objects.
  • 4. • Based on type of data, these controls could be divided into two categories: • Hierarchical data source controls • Table-based data source controls • The data source controls used for hierarchical data are: • XMLDataSource - It allows binding to XML files and strings with or without schema information. • SiteMapDataSource - It allows binding to a provider that supplies site map information.
  • 5. Data source controls Description SqlDataSource It represents a connection to an ADO.NET data provider that returns SQL data, including data sources accessible via OLEDB and QDBC. ObjectDataSource It allows binding to a custom .Net business object that returns data. LinqdataSource It allows binding to the results of a Linq-to-SQL query (supported by ASP.NET 3.5 only). AccessDataSource It represents connection to a Microsoft Access database.
  • 6. Data Source Views • Data source views are objects of the DataSourceView class. Which represent a customized view of data for different data operations such as sorting, filtering, etc. • The DataSourceView class serves as the base class for all data source view classes, which define the capabilities of data source controls.
  • 7. Properties Description CanDelete Indicates whether deletion is allowed on the underlying data source. CanInsert Indicates whether insertion is allowed on the underlying data source. CanPage Indicates whether paging is allowed on the underlying data source. CanRetrieveTotalRowCount Indicates whether total row count information is available. CanSort Indicates whether the data could be sorted. CanUpdate Indicates whether updates are allowed on the underlying data source. Events Gets a list of event-handler delegates for the data source view. Name Name of the view.
  • 8. Methods Description CanExecute Determines whether the specified command can be executed. ExecuteCommand Executes the specific command. ExecuteDelete Performs a delete operation on the list of data that the DataSourceView object represents. ExecuteInsert Performs an insert operation on the list of data that the DataSourceView object represents. ExecuteSelect Gets a list of data from the underlying data storage.
  • 9. ExecuteUpdate Performs an update operation on the list of data that the DataSourceView object represents. Delete Performs a delete operation on the data associated with the view. Insert Performs an insert operation on the data associated with the view. Select Returns the queried data. Update Performs an update operation on the data associated with the view. OnDataSourceView Changed Raises the DataSourceViewChanged event. RaiseUnsupported CapabilitiesError Called by the RaiseUnsupportedCapabilitiesError method to compare the capabilities requested for an ExecuteSelect operation against those that the view supports.
  • 10. The SqlDataSource Control • The SqlDataSource control represents a connection to a relational database such as SQL Server or Oracle database, or data accessible through OLEDB or Open Database Connectivity (ODBC). Connection to data is made through two important properties ConnectionString and ProviderName. • The following code snippet provides the basic syntax of the control: • <asp:SqlDataSource runat="server" ID="MySqlSource" ProviderName='<%$ ConnectionStrings:LocalNWind.ProviderName %>' ConnectionString='<%$ ConnectionStrings:LocalNWind %>' SelectionCommand= "SELECT * FROM EMPLOYEES" /> <asp:GridView ID="GridView1" runat="server" DataSourceID="MySqlSource" /> • Configuring various data operations on the underlying data depends upon the various properties (property groups) of the data source control.
  • 11. Property Group Description DeleteCommand, DeleteParameters, DeleteCommandType Gets or sets the SQL statement, parameters, and type for deleting rows in the underlying data. FilterExpression, FilterParameters Gets or sets the data filtering string and parameters. InsertCommand, InsertParameters, InsertCommandType Gets or sets the SQL statement, parameters, and type for inserting rows in the underlying database.
  • 12. SelectCommand, SelectParameters, SelectCommandType Gets or sets the SQL statement, parameters, and type for retrieving rows from the underlying database. SortParameterName Gets or sets the name of an input parameter that the command's stored procedure will use to sort data. UpdateCommand, UpdateParameters, UpdateCommandType Gets or sets the SQL statement, parameters, and type for updating rows in the underlying data store.
  • 13. The ObjectDataSource Control • The ObjectDataSource Control enables user-defined classes to associate the output of their methods to data bound controls. The programming interface of this class is almost same as the SqlDataSource control. • Following are two important aspects of binding business objects: • The bindable class should have a default constructor, it should be stateless, and have methods that can be mapped to select, update, insert, and delete semantics. • The object must update one item at a time, batch operations are not supported. • Let us go directly to an example to work with this control. The student class is the class to be used with an object data source. This class has three properties: a student id, name, and city. It has a default constructor and a GetStudents method for retrieving data.
  • 14. The AccessDataSource Control • The AccessDataSource control represents a connection to an Access database. It is based on the SqlDataSource control and provides simpler programming interface. The following code snippet provides the basic syntax for the data source: • <asp:AccessDataSource ID="AccessDataSource1 runat="server" DataFile="~/App_Data/ASPDotNetStepByStep.mdb" SelectCommand="SELECT * FROM [DotNetReferences]"> </asp:AccessDataSource> • The AccessDataSource control opens the database in read-only mode. However, it can also be used for performing insert, update, or delete operations. This is done using the ADO.NET commands and parameter collection. • Updates are problematic for Access databases from within an ASP.NET application because an Access database is a plain file and the default account of the ASP.NET application might not have the permission to write to the database file.
  • 15. Thank You For more updates on C#, ASP.NET, MVC, JAVASCRIPT, HTML, CSS tutorials subscribe to our YouTube channel SIRYMEDIA Visit our website for more www.sirymedia.in