Lecture Set 14 B new Introduction to Databases - Database Processing: The Connected Model (Using DataReaders)

Slides:



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

ADO vs ADO.NET ADOADO.NET Client/server coupledDisconnected collection of data from data server Uses RECORDSET object (contains one table) Uses DATASET.
By Chris Pascucci and FLF
Chapter 10 ADO. What is ADO? ADO is a Microsoft technology ADO stands for ActiveX Data Objects ADO is a programming interface to access data in a database.
Introduction to Database Processing with ADO.NET.
1 Pertemuan 09 Database Matakuliah: D0524 / Algoritma dan Pemrograman Komputer Tahun: 2005 Versi:
Query Execution Professor: Dr T.Y. Lin Prepared by, Mudra Patel Class id: 113.
Performed by:Gidi Getter Svetlana Klinovsky Supervised by:Viktor Kulikov 08/03/2009.
Introduction to ADO.Net, VB.Net Database Tools and Data Binding ISYS 512.
ASP.NET Programming with C# and SQL Server First Edition Chapter 8 Manipulating SQL Server Databases with ASP.NET.
Chapter 12 Database Connectivity with ASP.NET JavaScript, Third Edition.
From VS C# 2010 Programming, John Allwork 1 VS2010 C# Programming - DB intro 1 Topics – Database Relational - linked tables SQL ADO.NET objects Referencing.
Chapter 8 Binding Data to Web Controls. ASP.NET 2.0, Third Edition2.
CHAPTER 9 DATABASE MANAGEMENT © Prepared By: Razif Razali.
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.
Chapter 10 Managing Data with ASP.NET. ASP.NET 2.0, Third Edition2.
Introduction to ADO.Net and Visual Studio Database Tools ISYS 512.
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.
FEN Data connection DataReader DataSet Bonus info: Concurrency and Database Transactions Embedded SQL.
CIS 451: Using ASP.NET Objects with SQL Dr. Ralph D. Westfall February, 2009.
Web Services Week 8 Aims: –Using web services as front ends to databases Objectives: –Review of relational databases –Connecting to and querying databases.
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.
CHAPTER EIGHT Accessing Data Processing Databases.
1 Introduction to ADO.NET Microsoft ADO.NET 2.0 Step by Step Rebecca M Riordan Microsoft Press, 2006.
 It is the primary data access model for.Net applications  Next version of ADO  Can be divided into two parts ◦ Providers ◦ DataSets  Resides in System.Data.
Database, SQL, and ADO.NET- Part 1 Session 11 Mata kuliah: M0874 – Programming II Tahun: 2010.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 Working with Disconnected Data The DataSet and SqlDataAdapter ADO.NET - Lesson.
Copyright ©2004 Virtusa Corporation | CONFIDENTIAL ADO.Net Basics Ruwan Wijesinghe Trainer.
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.
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.
Christopher M. Pascucci.NET Programming: Databases & ADO.NET.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 Introduction to ADO.NET ADO.NET - Lesson 01  Training time: 10 minutes  Author:
ADO.NET Part 2. Slide 2 Overview Slide 3 Introduction to the DataGridView Control It’s a two-dimensional grid containing rows and columns Its use in.
Presented by Joseph J. Sarna Jr. JJS Systems, LLC
Module 3: Performing Connected Database Operations.
 It is the primary data access model for.Net applications  Next version of ADO  Can be divided into two parts ◦ Providers ◦ DataSets  Resides in System.Data.
Efficient RDF Storage and Retrieval in Jena2 Written by: Kevin Wilkinson, Craig Sayers, Harumi Kuno, Dave Reynolds Presented by: Umer Fareed 파리드.
The Problems HTTP is disconnected So many database vendors Create a simple consistent versatile interface on the data Look at ADO.NET classes OleDb SQL.
Mauricio Featherman, Ph.D. Washington St. University
Introduction to ADO.Net and VS Database Tools and Data Binding ISYS 350.
DATABASE CONNECTIVITY TO MYSQL. Introduction =>A real life application needs to manipulate data stored in a Database. =>A database is a collection of.
Databases and ADO.NET Programming Right from the Start with Visual Basic.NET 1/e 11.
HNDIT Rapid Application Development
Module 4 Introduction ADO.NET.
C# .NET Software Development
Active Data Objects Using.Net ADO.Net Farooq Ahmed Amna Umber Summayya Shehzad.
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.
Introduction to ADO.Net and Visual Studio Database Tools ISYS 350.
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.
Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe.
.NET Data Access and Manipulation
ASP.NET Programming with C# and SQL Server First Edition
Introduction to ADO.NET
Introduction to Database Processing with ADO.NET
Introduction to Database Processing with ADO.NET
ADO.NET Framework.
Programming the Web Using ASP.Net
Lecture 6 VB.Net SQL Server.
VB.NET Using Database.
Lecture Set 14 B new Introduction to Databases - Database Processing: The Connected Model (Using DataReaders)
Chapter 10 ADO.
.NET Framework Data Providers
M S COLLEGE OF ART’S, COMM., SCI. & BMS Advance Web Programming
Introduction to ADO.Net and Visual Studio Database Tools.
Presentation transcript:

Lecture Set 14 B new Introduction to Databases - Database Processing: The Connected Model (Using DataReaders)

Slide 2 Objectives Understand database processing using ADO.NET Perform specialized database processing tasks Work with database data programmatically using either DataReaders (connected mode) DataSets (disconnected mode) We discuss DataReaders here and will DataSets in Lecture Set 14C

Slide 3 DataReader The DataReader is an component used for read-only and forward-only connection to a database. It is used to execute a query via a connection to a database and iterate through the data returned by the database. The abstraction provided here is that of a connected data architecture.

Slide 4 DataReader

Slide 5 Wizards and Bound Data vs DataReaders and DataSets Wizard and data bound fields are useful for the rapid development of forms and displays based on content of a database They are not useful for most transaction processing systems because of inflexibility Use of code to control database access is more powerful because the programmer can manipulate data before it is stored or after it is retrieved I prefer to avoid wizards where possible

Slide 6 The Processing Sequence Holds for both connected and disconnected architectures Establish a connection to your data source using a Connection Object These objects are simple to construct Create an SQL statement (a string) and wrap it in a Command object These strings are harder to build – more detailed Execute the Command object within the context of the Connected DB – there are methods for this Process (retrieve or store) results of command if there are any Use a DataReader object to scan through records [Use a combination of a DataAdapter and DataSet (or DataTable) objects for storage and retrieval] Close all objects you opened to process data

Slide 7 The Primary Objects The Connection Object – Directs communication between your program and Data Source. Handles location and connection parameters for the data source. The Command Object – Takes an SQL statement you provide (as a string) and prepares it for transport through the Connect- ion Object and subsequent processing in the specified DBMS. The DataReader Object – Provides a simple and efficient way to retrieve results from an SQL query. It is used by other objects in ADO.NET to retrieve and redirect data within your program. You can use this reader directly to process the result of a SELECT or other retrieval action. The DataAdapter Object – Enables communication between a DataSet and the rest of the Provider. Modifies SELECT, DELETE, INSERT, and UPDATE statements for us by related data source (see Ch 11 Part C -- once it is done). More on this in Part C.

Slide 8 DataReader Example

Slide 9 Example: Insert a Record

Slide 10 Example: Delete a Record

Slide 11 Example: Update a Record

Slide 12 ADO.NET

Slide 13 DataReaders – main use DataReaders Simple and efficient way to retrieve results from a query Can use directly to process results of a select or or to provide direct access INSERTs, DELETEs, and UPDATEs A query gives you access to one row of table information at a time Your connection must be open before a command is executed and should be closed when you are done

Slide 14 Using DataReaders

Slide 15 The OleDbCommand Class The OleDbCommand class stores SQL statements The Connection property stores a reference to an OleDbConnection The CommandText property stores an SQL statement The CommandType should be set to Text

Slide 16 DataSets vs DataReaders 1 DataReaders retrieve data in read only form. Data in a DataSet may be modified in memory and updated in one step DataReaders allocate memory to one record (one table row) of data at a time. Efficient. Little overhead. DataSets are less efficient. Space must be allocated for entire table involved. Only one record at a time can be processed. Random access through entire DataSet possible. Only one DataReader can be open at a time. Multiple DataSets can be open at once.

Slide 17 DataSets vs DataReaders 2 Live connection to the database exists as long as the DataReader is open. Data connections maintained only long enough to transfer data between DataSet and database. With DataReaders you spend a lot of time working with strings (for SQL statements) and raw data fields (You supply all SQL statements). DataSets and DataAdapters assist in crafting SQL statements for you. All fields in a DataSet have the same logical organization as in the actual database.

Slide 18 Examples (Finally) Illustrations of various DB commands Pattern of use of methods that are part of the collection of class libraries that support “Providers” technology is complete consistent Create a connection, dbCon, between your (client) code and the database Build a database command (SQL select, update, insert, or delete ) as a VB string s Send the string and connection information via a command to the provider

Slide 19 Example 1 – Insert (plus a simple select) (Uses Insert and dataReader commands to effect data transmission) Direct insert of transaction into DB

Slide 20 Example 2 – Saving current record data

Slide 21 Example 3 – Using Max Transaction ID Commit list of transactions to a DB

Slide 22 Example 4 – Delete (remove) a record

Slide 23 Example 5 – Update a Record

Slide 24 The Plan of Action The goal is to have you work on Phase 2 of your lab using DataReaders Then – as time permits, we will migrate over to the ASP.NET (client-server world) using Datasets REMEMBER with DataReaders (in connected mode) all commands are executed on the database itself – not on any internal representation of the database. To better understand the connected mode, study your HW #10 Employee-Manager code