Download presentation
Presentation is loading. Please wait.
Published byJulius Harrison Modified over 8 years ago
1
Working with Data Lesson 4
2
Objectives
3
DataSource Controls A requirement for most modern Web sites is that they be dynamic. –Static pages are not often revisited. One of the most efficient ways to accomplish this is by connecting Web pages to a database, and ASP.NET provides all the controls you need. Most of the Microsoft DataSource controls are capable of reading data as well as changing the data at the source.
4
LinqDataSource Control The LinqDataSource control is the latest control used for the communication between ASP.NET Web pages and the database. –It can be applied without having to type a single line of code. –The developer can opt to have all code written automatically by ASP.NET.
5
Adding the LINQ Connection
6
ObjectDataSource Control Unlike the LinqDataSource, the ObjectDataSource control does not retrieve data from a database. The purpose of this object is to move any needed data connections along with any needed Input/Output activities of the database, or any other data source, to a location outside the Web page. A Web page does not need to know where the data is coming from nor where it is going. All the page needs to do is ask the ObjectDataSource for the data when it needs it and send it to the ObjectDataSource to save changes.
7
XmlDataSource In its simplest form, the XmlDataSource control is a rather crude control because it is incapable of deciphering the language of XML. However, when used with a file that provides the rules, it becomes a complex powerhouse for handling XML documents.
8
SqlDataSource The SqlDataSource control enables you to connect and interact with any database supported by ADO.NET.
9
Binding Controls To make your page a little more dynamic, you may want to perform the data binding in code.
10
Connecting the GridView Control
11
Data-Aware Controls The simplest definition of ASP.NET data- aware controls is that they are all the controls having the DataSource and DataSourceID properties. Data-bound controls, on the other hand, are data-aware controls that have been bound to a specific data source. It is not required for all data-aware controls to be data-bound.
12
Data-Aware Controls Standard Category DropDownList ListBox CheckBoxList RadioButtonList BulletedList AdRotator Data Category GridView DataList DetailsView FormView Repeater ListView Navigation Category Menu TreeView
13
Adding Items to an Unbound Data-Aware Control
14
Managing Data Connections and Databases ASP.NET uses ADO.NET to handle all of its database connections. The compiled code that ASP.NET generates from your.NET programs and objects is called managed code. Managed code is created to run on Microsoft’s Common Language Runtime (CLR) rather than creating an executable that is limited to a particular hardware platform.
15
Managing Data Connections and Databases ADO.NET also allows us to write provider-independent code so the program is able to connect to a variety of data sources. Several of the.NET database connections are also referred to as data providers because each is designed to work with specific database management systems. Microsoft’s Component Object Model (COM), introduced in 1993, is a technology that enables software components to communicate. –The database is only one of the many components that COM manages.
16
Providing Data for ADO.NET Applications There are two basic categories to provide data for ADO.NET applications: –Direct connections to specific data sources –The more general connections that provide connectivity to a variety of data sources. The direct connections, such as the SQLConnection, are faster and more efficient than the general connections. However, these more general connections, such as ODBC and OleDB, have the important role of connecting to many of the legacy data sources.
17
IntelliSense Lists ADO.NET Namespaces for Both New and Old Ways for Database Communication
18
Using ADO.NET to Connect to ODBC
19
Using ADO.NET to Connect to OleDB
20
Connection Object The database connection object is the closest object to the data source. You have three connection objects to connect to our database: –SqlConnection –OleDB –ODBC
21
Connection Pool A connection pool is a collection of open data connections that Web applications presumed were closed. All.NET data providers support connection pooling including SQL Server, OleDB, ODBC, and Oracle. Although there are many settings available for us to use to fine-tune the service, most applications work fine with the defaults. If changes are made, third-party applications are available to monitor the changes in performance or you can write your own simulations.
22
Transaction Objects A transaction object allows multiple SQL statements to be processed as a group. If any of the statements in the group fail, all the statements in the group that have been processed will be rolled back and the whole transaction is aborted. ASP.NET includes the transaction object that allows us to do this in code.
23
ACID Test for Transactions
24
Summary Using the LinqDataSource control. Using the ObjectDataSource control. Using the XmlDataSource control. Using the SqlDataSource control. Using data-binding syntax. Using a data-aware control. Examining database connections.
25
Summary Using the OleDB connection object. Using the OdbcConnection object. Using the connection pool. Using the transaction object.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.