12
Module 9: Accessing Relational Data Using Microsoft Visual Studio .NET

Module 9: Accessing Relational Data Using Microsoft Visual Studio.NET

Embed Size (px)

Citation preview

Module 9:

Accessing Relational Data Using Microsoft Visual Studio .NET

Overview

Overview of ADO.NET Creating a Connection to a Database Displaying a DataSet in a List-Bound

Control

Lesson: Overview of ADO.NET What is ADO.NET? Using Namespaces The ADO.NET Object Model What is a DataSet? Accessing Data with ADO.NET Practice: Identifying ADO.NET Components

ADO.NET provides a set of classes for working with data. ADO.NET provides:

An evolutionary, more flexible successor to ADO A system designed for disconnected environments A programming model with advanced XML support A set of classes, interfaces, structures, and enumerations

that manage data access from within the .NET Framework

What is ADO.NET?

Using NamespacesNamespaces used with ADO.NET include:

•System.Data.SqlClient•System.Data.OleDb•System.Data.Odbc•System.Data.OracleClient

DataSet

SQL Server .NET Data Provider

OLE DB .NET Data Provider

SQL Server 7.0(and later)

OLEDB sources(SQL Server 6.5)

OleDbConnectionOleDbConnection

OleDbDataAdapterOleDbDataAdapterSqlDataAdapterSqlDataAdapter

SqlConnectionSqlConnection

DataTable

DataTable

The ADO.NET Object Model

SQL Server 2000

DataSet

DataTable

DataTable

Physical storage

OleDb Database

SqlDataAdapterSqlDataAdapter

SqlConnectionSqlConnection

DataTable

Web server memory

OleDbDataAdapterOleDbDataAdapter

OleDbConnection

OleDbConnection

What is a Dataset?

Accessing Data with ADO.NETDatabaseDatabase

4. Return the DataSet to the Client

5. Client manipulates the data

2. Create the SqlConnection and SqlDataAdapter objects

3. Fill the DataSet from the DataAdapter and close the connection SqlDataAdapter

SqlConnection

List-Bound

Control

List-Bound

Control

1. Client makes request1111

2222

3333

4444

5555

6. Update the DataSet

7. Use the SqlDataAdapter to open the SqlConnection, update the database, and close the connection

6666

7777

ClientClient

Web serverWeb server

DataSet

Lesson: Creating a Connection to a Database

Using Server Explorer to Generate a Connection The DataAdapter Object Model Demonstration: Connecting to a Database Generating a DataSet Demonstration: Generating a DataSet

Using Server Explorer to Generate a Connection

Create a new data connection by dragging a Table from Server Explorer

Create a new data connection using the Data Links dialog box

The DataAdapter Object Model

sp_SELECT

CommandCommand

SelectCommand UpdateCommand InsertCommand DeleteCommand

DataAdapter

CommandCommand CommandCommand CommandCommand

ConnectionConnection

sp_UPDATE sp_INSERT sp_DELETE

Database

DataSetDataSet

DataReaderDataReader

Review

Overview of ADO.NET Creating a Connection to a Database