Introduction to ASP.NET

Download Report

Transcript Introduction to ASP.NET

Overview of Data Access
MacDonald Ch. 15
MIS 324
Professor Sandvig
Overview




ADO.NET overview
Datasets & Datatables
Data Access
Displaying data

Web Controls
ADO.NET Overview

“Any web application worth writing involves
data access.”
Stephen Walther

ADO
 ActiveX Data Objects
 Microsoft’s data access technologies
 Set of classes that provide data access
services
 Class Library System.Data
ADO.NET Overview

Data sources include:





relational databases
XML files
Web Services
Text files, etc…
Goal

loose coupling between data source and application

minimize dependencies
DataSet & DataTable


Dataset is object for holding data
Central feature of ADO.NET


Provides tools for working with data
DataSet is a collection of DataTables

Relationships between tables
Data Sources:
Web Controls:
Relational database
XML file
Web Service
Text file
etc…
Dataset
(data tables)
List controls
Tabular controls
Navigation controls
DataSet & DataTable

Provides many capabilities of relational database






Relationships
Keys
Referential integrity
Dataviews: sort and filtering
Change history
Data stored as XML

Behind the scenes
.NET Data options
1.
Programmatically

Use connection & command objects



2.
Very flexible approach
Similar to PHP
Data Source Controls




3.
Pass SQL to database
Drag & drop in Visual Studio
Declarative approach
Easy but inflexible
Added in .NET 2.0
Entity Framework



Creates objects representing database structure
Query with SQL or Entity SQL
Added to .NET 3.5
Retrieving Data

MIS 324


Will use programmatic approach
Benefits



Flexible
Uses standard OOP programming techniques
MIS 424


Data Source Controls
Entity Framework
Displaying Data
Steps:
1. Retrieve data from datasource
2. Fill DataTable
3. “Bind” to web control
a.
b.
c.
List controls (1 column)
Tabular controls (>1 column)
Single record controls
B. Displaying Data


Bind datatable to web control
Web Controls



List Controls
Tabular Controls
Single record controls
Example: source, output
Summary

ADO.NET
1.
2.

Dataset



Memory resident data container
Bind to Web Controls
Web Controls


Classes that handle data access
Provides consistent programming interface to data
sources
Write HTML & data to client
Next: SQL Server Express

Creating databases & using with ASP.NET