
Implementing Object Data Sources in ADO.NET for ASP.NET Applications
Learn how to utilize Object Data Sources with ADO.NET for building robust 3-layer ASP.NET applications. Explore topics like configuring ObjectDataSource controls, creating data access classes, and working with bound controls to enhance your database application development.
Download Presentation

Please find below an Image/Link to download the presentation.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.
You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.
E N D
Presentation Transcript
How to use Object Data sources with ADO.NET(pages [551-569]) By Naga Krishna Ganta Presentation ID: 10
Outline An introduction to ObjectData Sources How 3-layer applications work in ASP.NET How to use ObjectDataSource control How to configure an ObjectDatasource control How to work with bound controls A Product List application The aspx file The productDB class How to create a data access class How to design data access class How to create a select method
How 3-layer applications work in ASP.NET An object data source is implemented by the ObjectDataSource control, lets you use data binding with the 3-layer architecture for a database application. An Object data source is similar to a SQL data source. However, instead of directly accessing a database, the object data source gets its data through a data class that handles the details of database access. A 3-layer architecture separates the presentation, business rules and Data access components of application. The 3-layers of architecture are: Presentation Layer Middle Layer Database Layer
Presentation Layer Consists ofASP.NET pages that manage the appearance of the application Includes bound Data controls and ObjectDataSource objects that bind the data controls to the data. Middle Layer Contains the data access classes that manage the data access for the application. Contains business objects that represent business entities such as customers, products, or employees and that implement business rules such as credit and discount policies. Database layer Consists of database that contains data for the application. The SQL statements that do the database access should be saved in stored procedures within the database. But SQL classes are often stored in the data access classes.
How to use ObjectDataSource control The ObjectDataSource control specifies the name of the data access class and the methods used to select, update, delete and insert data.
How to configure an ObjectDataSourceControl
ProductDBclass A class file is added to App_Code folder using add new item. Two methods are created GetAllCatergories and GetProductByCategory Another method GetConnectionString is created which is declared as private GetAllCatergories method starts by creating a connection to Halloween databases by calling GetConnectionString method Now this methods creates a string which contains the select statement that will retrieve the data from Halloween database Finally the connection is opened Execute reader method of the command object is called and object that contains the requested data is returned to object data source
How to create a data access class The most challenging aspect of object data source is developing data access class Data access class have four different types of methods that are used to select, insert, update and delete data. For example; ProductDB class uses select method Data access method can be static or instance methods The preferred is static method to select, insert, delete and update where ever possible.
How to create select method Select statement returns data retrieved from databases Data could be of any form dataset or datatable If the select method returns datatable, the objectdatasource control automatically extracts a dataview from the table and uses view for data binding If select method returns dataset, ObjectDataSource control extracts data view from first data tablein dataset and uses the view for data binding