Module 2: Using ADO.NET to Access Data. Overview ADO.NET Architecture Creating an Application That Uses ADO.NET to Access Data Changing Database Records.

Slides:



Advertisements
Similar presentations
17. Data Access ADO.Net Architecture New Features of ADO.NET
Advertisements

ADO.NET: Working in Disconnected Environment Sergey Baidachni MCT, MCSD, MCDBA.
Chapter 10 Database Applications Copyright © 2011 by The McGraw-Hill Companies, Inc. All Rights Reserved. McGraw-Hill.
Chapter 18 - Data sources and datasets 1 Outline How to create a data source How to use a data source How to use Query Builder to build a simple query.
Introduction to Database Processing with ADO.NET.
VB.NET Database Access ISYS546. Microsoft Universal Data Access ODBC: Open Database Connectivity –A driver manager –Used for relational databases OLE.
Chapter 12: ADO.NET and ASP.NET Programming with Microsoft Visual Basic.NET, Second Edition.
Using ADO.NET Chapter Microsoft Visual Basic.NET: Reloaded 1.
ASP.NET Database Connectivity I. 2 © UW Business School, University of Washington 2004 Outline Database Concepts SQL ASP.NET Database Connectivity.
VB.NET Database Access ISYS 812. Microsoft Universal Data Access ODBC: Open Database Connectivity –A driver manager –Used for relational databases OLE.
Programming in ADO.NET: Data-Centric Applications and ADO.NET Original copyright by Microsoft, 2002, with minor modifications by Dan Eaves, 2005.
Chapter 8 Binding Data to Web Controls. ASP.NET 2.0, Third Edition2.
Chapter 9 Using the SqlDataSource Control. References aspx.
Chapter 11 Introduction to Database Processing. Class 11: Database Processing Use a Visual Studio Wizard to establish a database connection used to load.
Programming with Visual Basic.NET An Object-Oriented Approach  Chapter 8 Introduction to Database Processing.
Introduction to ADO.Net and Visual Studio Database Tools ISYS 512.
Visual Studio ®.NET Data with XML Carlotta Eaton ( Associate Professor of IST New River Community College Slides by Microsoft Modified.
Chapter 61 Managing Data Sources Introduction to ASP.NET By Kathleen Kalata.
10-1 aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf.
ADO.NET Tools and Wizards. Slide 2 Data Sources Window (Introduction) Use the Data Sources window to Establish a connection Create bound control instances.
ADO.NET A2 Teacher Up skilling LECTURE 3. What’s to come today? ADO.NET What is ADO.NET? ADO.NET Objects SqlConnection SqlCommand SqlDataReader DataSet.
Developing Web Applications Using Microsoft ® Visual Studio ® 2008.
A Simple Introduction. What is ADO.net? First the word ADO stands for ActiveX Data Objects And it is an integral part of.Net Framework of Microsoft hence.
Lecture Set 14 B new Introduction to Databases - Database Processing: The Connected Model (Using DataReaders)
Needs for Accessing Database To make your web site more dynamic and maintainable, you can display information on your web pages that are retrieved from.
Databases and Data Access  Introduction to ADO.NET  ADO.NET objects  ADP.NET namespaces  Differences between ADO and ADO.NET.
CHAPTER EIGHT Accessing Data Processing Databases.
.NET Data Access and Manipulation ADO.NET. Overview What is ADO.NET? Disconnected vs. connected data access models ADO.NET Architecture ADO.NET Core Objects.
CHAPTER EIGHT Accessing Data Processing Databases.
Introduction to Database Development Using Borland Data Providers 2128 Martin Rudy.
1 Introduction to ADO.NET Microsoft ADO.NET 2.0 Step by Step Rebecca M Riordan Microsoft Press, 2006.
Moving from Microsoft ® ADO 2.X To ADO.NET Jackie Goldstein Renaissance Computer Systems Ltd. MSDN Regional Director, Israel Prerequisites.
Objectives In this lesson, you will learn to: *Identify the need for ADO.NET *Identify the features of ADO.NET *Identify the components of the ADO.NET.
ASP.NET Rina Zviel-Girshin Lecture 5
Module 9: Accessing Relational Data Using Microsoft Visual Studio.NET.
Session 8: ADO.NET. Overview Overview of ADO.NET What is ADO.NET? Using Namespaces The ADO.NET Object Model What is a DataSet? Accessing Data with ADO.NET.
Module 7: Accessing Data by Using ADO.NET
Christopher M. Pascucci.NET Programming: Databases & ADO.NET.
Module 4: Building DataSets. Overview Working in a Disconnected Environment Building DataSets and DataTables Binding and Saving a DataSet Defining Data.
Lecture Set 14 B new Introduction to Databases - Database Processing: The Connected Model (Using DataReaders)
An Introduction to ADO.Net Marmagna Desai.NET Seminar, Fall-2003.
1 Chapter 20 – Data sources and datasets Outline How to create a data source How to use a data source How to use Query Builder to build a simple query.
Mauricio Featherman, Ph.D. Washington St. University
DEV383 The ADO.NET DataSet and You Jackie Goldstein General Manager Renaissance Computer Systems
Module 4: Creating a Web Application with Web Forms
Databases and ADO.NET Programming Right from the Start with Visual Basic.NET 1/e 11.
Module 3: Working with Local Data. Overview Using DataSets Using XML Using SQL Server CE.
HNDIT Rapid Application Development
ADO.NET FUNDAMENTALS BEGINNING ASP.NET 3.5 IN C#.
Module 4 Introduction ADO.NET.
1 Database Programming with ADO.NET Kashef Mughal.
Module 5 Data Classes DataView – DataGridView Control 1.
Data Access. ADO.NET ADO.NET is the primary library for building database solutions within the.NET Framework. ADO.NET does not replace ADO. ADO and OLEDB.
ADO .NET from. ADO .NET from “ADO .Net” Evolution/History of ADO.NET MICROSOFT .NET “ADO .Net” Evolution/History of ADO.NET History: Most applications.
.NET Data Access and Manipulation
DAT 390 Advanced ADO.NET Programming Techniques Jackie Goldstein Renaissance Computer Systems
Integrating Data Lesson 6.
Introduction to Database Processing with ADO.NET
ADO.NET Framework.
Lecture 6 VB.Net SQL Server.
Active Data Objects Binding ASP.NET Controls to Data
ADO.NET Accessing Databases in VS.NET
VB.NET Using Database.
Tonga Institute of Higher Education
Module 10: Creating a Web Application with Web Forms
PROG Advanced Web Apps 4/13/2019 Programming Data Pages Wendi Jollymore, ACES.
Chapter 10 Accessing Database Files
Visual Studio + SQL Server Is Better
Active Data Objects Binding ASP.NET Controls to Data
Introduction to Database Programming through ADO. NET
Presentation transcript:

Module 2: Using ADO.NET to Access Data

Overview ADO.NET Architecture Creating an Application That Uses ADO.NET to Access Data Changing Database Records

Lesson: ADO.NET Architecture What Is ADO.NET? What Is a Connected Environment? What Is a Disconnected Environment? What Is the ADO.NET Object Model? What Is the DataSet Class? What Is the.NET Data Provider?

What Is ADO.NET? ADO.NET is a data access technology. It provides: A set of classes, interfaces, structures, and enumerations that manage data access from within the.NET Framework An evolutionary, more flexible successor to ADO A system designed for disconnected environments A programming model with advanced XML support

What Is a Connected Environment? A connected environment is one in which users are constantly connected to a data source Advantages: Environment is easier to secure Concurrency is more easily controlled Data is more likely to be current than in other scenarios Disadvantages: Must have a constant network connection Scalability

What Is a Disconnected Environment? In a disconnected environment, a subset of data from a central data store can be copied and modified independently, and the changes merged back into the central data store Advantages You can work at any time that is convenient for you, and can connect to a data source at any time to process requests Other users can use the connection A disconnected environment improves the scalability and performance of applications Disadvantages Data is not always up to date Change conflicts can occur and must be resolved

What Is the ADO.NET Object Model? DatabaseDatabase.NET Data Provider Connection Transaction Command Parameters DataReader DataAdapter SelectCommand InsertCommand UpdateCommand DeleteCommand DataSet DataTableCollection DataTable DataRowCollection DataColumnCollection ConstraintCollection DataRelationCollection XMLXML

Multimedia: Using ADO.NET to Access Data

What Is the DataSet Class? DataSet Constraints Table Column Constraint Rows Row Relations Relation Object Collection Tables Columns DataSets consist of one or more tables and relations Loaded from one or more data adapters Created as you work Loaded from XML Loaded from other DataSets Tables contain columns, constraints, and rows All are collections!

What Is the.NET Data Provider? Manages the connection to a database Executes a query command on the database Exchanges data between the data set and the database Provides efficient access to a stream of read-only data DatabaseDatabase Connection Command DataReader DataAdapter

Practice: ADO.NET Architecture Matching Practice 10 min

Lesson: Creating an Application That Uses ADO.NET to Access Data How to Specify the Database Connection How to Specify the Database Command How to Create the DataAdapter Object How to Create a DataSet Object How to Bind a DataSet to a DataGrid How to Use the Data Wizards in Visual Studio.NET

How to Specify the Database Connection Use the Connection object to: Choose the connection type Specify the data source Open the connection to the data source Use the connection string to specify all of the options for your connection to the database, including the account name, database server, and database name string connectionStr Source=localhost; Integrated Security=SSPI; Initial Catalog=northwind";

How to Specify the Database Command Create a string containing SQL statements Remember that Verbatim strings can make this much easier! Examples of SQL statements: SELECT * FROM Customers SELECT CustomerName FROM Customers SELECT * FROM Customers WHERE Country = 'Mexico' string CustomerName, CompanyName FROM Customers";

How to Create the DataAdapter Object Data source DataAdapter DataTable DataSet DataAdapter Fill Update Fill

How to Create a DataSet Object DataSet Constraints Table Column Constraint Rows Row Relations Relation Object Collection Tables Columns Use Fill method of DataAdapter Populate programmatically by creating a table structure and filling it Read an XML document or stream into a DataSet Use Merge method to copy the contents of another DataSet object

How to Bind a DataSet to a DataGrid To bind programmatically DataGrid dataGrid1 = new DataGrid(); sqlDataAdapter1.Fill(dataSet1, "Customers"); sqlDataAdapter2.Fill(dataSet1, "Orders"); dataGrid1.DataSource = dataSet1; DataGrid dataGrid1 = new DataGrid(); sqlDataAdapter1.Fill(dataSet1, "Customers"); sqlDataAdapter2.Fill(dataSet1, "Orders"); dataGrid1.DataSource = dataSet1;

Demonstration: Using the Data Wizards in Visual Studio.NET In instructor-led demonstration will show you how to use the Data Adapter Configuration Wizard, how to use the Server Explorer, and how to use the Data Form Wizard

How to Use the Data Wizards in Visual Studio.NET

Practice: Using the Data Adapter Configuration Wizard In this practice you will add a new database record to the Shippers table in the Northwind Traders database You will use the Data Adapter Configuration Wizard in Visual Studio.NET to generate most of the code In this practice you will add a new database record to the Shippers table in the Northwind Traders database You will use the Data Adapter Configuration Wizard in Visual Studio.NET to generate most of the code Guided Practice 10 min

Lesson: Changing Database Records How to Access Data in a DataSet Object How to Update a Database in ADO.NET How to Create a Database Record How to Update a Database Record How to Delete a Database Record

DataRow objects How to Access Data in a DataSet Object DataColumn objects DataTable objects DataColumn objects

How to Update a Database in ADO.NET DataSet Client DataAdapter DatabaseDatabase Server Data Fill Update DeleteCommand UpdateCommand InsertCommand Data DataTable

How to Create a Database Record Create a new row that matches the table schema Add the new row to the dataset Update the database DataRow myRow = dataTable.NewRow(); sqlDataAdapter1.Update( dataSet ); dataTable.Rows.Add( myRow );

How to Update a Database Record Modify the row containing the record Generate a new dataset containing the changes Check the new dataset for errors Merge the changes back into the original dataset Call the Update method on the data adapter Call the AcceptChanges method on your original dataset

How to Delete a Database Record Delete the row from the dataset Update the database Accept the changes to the dataset dataTable.Rows[0].Delete(); dataSet.AcceptChanges(); dataAdapter.Update(dataSet);

Practice: Updating a Database Record In this practice, you will create and delete a database record, experimenting with the Update, AcceptChanges and RejectChanges methods Guided Practice 10 min

Review ADO.NET Architecture Creating an Application That Uses ADO.NET to Access Data Changing Database Records

Lab 7.1: Creating a Data Access Application with ADO.NET Exercise 1: Creating a simple database table viewer Exercise 2: Writing a Simple Database Table Viewer Exercise 3 (if time permits): Creating a simple database viewer 1 hour

Lab 7.2 (optional): Creating a Windows Application That Uses ADO.NET Exercise 1: Creating a Windows Application that uses ADO.NET Exercise 2 (if time permits): Writing an ADO.NET Application with Windows Forms 1 hour