Docsity

ASP.NET Database Access: Retrieving and Displaying Data using SqlDataSource and GridView, Exercises of Computer Programming

Toggle sidebar
bg1
ASP.NET - Database Access
ASP.NET allows the following sources of data to be accessed and used:
Databases (e.g., Access, SQL Server, Oracle, MySQL)
XML documents
Business Objects
Flat files
ASP.NET hides the complex processes of data access and provides much higher level
of classes and objects through which data is accessed easily. These classes hide all
complex coding for connection, data retrieving, data querying, and data manipulation.
ADO.NET is the technology that provides the bridge between various ASP.NET control
objects and the backend data source. In this tutorial, we will look at data access and
working with the data in brief.
Retrieve and display data
It takes two types of data controls to retrieve and display data in ASP.NET:
A data source control - It manages the connection to the data, selection of
data, and other jobs such as paging and caching of data etc.
A data view control - It binds and displays the data and allows data
manipulation.
We will discuss the data binding and data source controls in detail later. In this section,
we will use a SqlDataSource control to access data and a GridView control to display
and manipulate data in this chapter.
We will also use an Access database, which contains the details about .Net books
available in the market. Name of our database is ASPDotNetStepByStep.mdb and we
will use the data table DotNetReferences.
The table has the following columns: ID, Title, AuthorFirstName, AuthorLastName,
Topic, and Publisher.
Here is a snapshot of the data table:
pf3
pf4
pf5

Partial preview of the text

Download ASP.NET Database Access: Retrieving and Displaying Data using SqlDataSource and GridView and more Exercises Computer Programming in PDF only on Docsity!

ASP.NET - Database Access

ASP.NET allows the following sources of data to be accessed and used:  Databases (e.g., Access, SQL Server, Oracle, MySQL)  XML documents  Business Objects  Flat files ASP.NET hides the complex processes of data access and provides much higher level of classes and objects through which data is accessed easily. These classes hide all complex coding for connection, data retrieving, data querying, and data manipulation. ADO.NET is the technology that provides the bridge between various ASP.NET control objects and the backend data source. In this tutorial, we will look at data access and working with the data in brief.

Retrieve and display data

It takes two types of data controls to retrieve and display data in ASP.NET:  A data source control - It manages the connection to the data, selection of data, and other jobs such as paging and caching of data etc.  A data view control - It binds and displays the data and allows data manipulation. We will discuss the data binding and data source controls in detail later. In this section, we will use a SqlDataSource control to access data and a GridView control to display and manipulate data in this chapter. We will also use an Access database, which contains the details about .Net books available in the market. Name of our database is ASPDotNetStepByStep.mdb and we will use the data table DotNetReferences. The table has the following columns: ID, Title, AuthorFirstName, AuthorLastName, Topic, and Publisher. Here is a snapshot of the data table:

Let us directly move to action, take the following steps: (1) Create a web site and add a SqlDataSourceControl on the web form. (2) Click on the Configure Data Source option. (3) Click on the New Connection button to establish connection with a database.

(8) Finally execute the application. The content file code is as given: <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="dataaccess.aspx.cs" Inherits="datacaching.WebForm1" %>

Untitled Page