ADO.Net TableAdapters and TableAdapterManager Code Camp 2008 Emmet Gray

Slides:



Advertisements
Similar presentations
DB glossary (focus on typical SQL RDBMS, not XQuery or SPARQL)
Advertisements

ADO vs ADO.NET ADOADO.NET Client/server coupledDisconnected collection of data from data server Uses RECORDSET object (contains one table) Uses DATASET.
 Open the Paradise.exe file  Application displays records in the Books database  Allows the store manager to enter an author’s name (or part of a name)
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.
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.
Ch. 101 Changing the Contents of a Database. Ch. 102 Changing the Contents of a Database Data grid views can also be used to add, modify, and delete records.
Fundamentals, Design, and Implementation, 9/e Chapter 11 Managing Databases with SQL Server 2000.
1 Relational Model. 2 Relational Database: Definitions  Relational database: a set of relations  Relation: made up of 2 parts: – Instance : a table,
INTEGRITY Enforcing integrity in Oracle. Oracle Tables mrobbert owner granted access.
A tour of new features introducing LINQ. Agenda of LINQ Presentation We have features for every step of the way LINQ Fundamentals Anonymous Functions/Lambda.
From VS C# 2010 Programming, John Allwork 1 VS2010 C# Programming - DB intro 1 Topics – Database Relational - linked tables SQL ADO.NET objects Referencing.
Enterprise Object Framework. What is EOF? Enterprise Objects Framework is a set of tools and resources that help you create applications that work with.
Entity Framework Code First End to End
Database Design for DNN Developers Sebastian Leupold.
Introduction –All information systems create, read, update and delete data. This data is stored in files and databases. Files are collections of similar.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 10 Database Performance Tuning and Query Optimization.
10-1 aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf.
1 Overview of Databases. 2 Content Databases Example: Access Structure Query language (SQL)
Learningcomputer.com SQL Server 2008 – Entity Relationships in a Database.
Introduction to SQL Steve Perry
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.
Microsoft Visual Basic 2010: Reloaded Fourth Edition Chapter Twelve Access Databases and LINQ.
Lecture Set 14 B new Introduction to Databases - Database Processing: The Connected Model (Using DataReaders)
.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.
SQL Server 7.0 Maintaining Referential Integrity.
Introduction to LINQ Lecture # 19 August Introduction How do you interrogate/manipulate data? What if you could do the work in a type-safe," string-free.
1 Introduction to ADO.NET Microsoft ADO.NET 2.0 Step by Step Rebecca M Riordan Microsoft Press, 2006.
Copyright © 2005 Ed Lance Fundamentals of Relational Database Design By Ed Lance.
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.
SQL: DDL. SQL Statements DDL - data definition language –Defining and modifying data structures (metadata): database, tables, views, etc. DML - data manipulation.
Christopher M. Pascucci.NET Programming: Databases & ADO.NET.
Presented by Joseph J. Sarna Jr. JJS Systems, LLC
ADO.NET. ADO.NET is a new, improved, and greatly expanded version of ADO that was developed for the Microsoft.NET initiative It incorporates all of the.
Lecture Set 14 B new Introduction to Databases - Database Processing: The Connected Model (Using DataReaders)
1 Database Systems Introduction to Microsoft Access Part 2.
Chapter 4 Constraints Oracle 10g: SQL. Oracle 10g: SQL 2 Objectives Explain the purpose of constraints in a table Distinguish among PRIMARY KEY, FOREIGN.
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
Indexes and Views Unit 7.
DataSet Your Database student test score Database Connection Your program needs to establish a connection to the database. Click on “Add New Data Source.”
SQL/Lesson 7/Slide 1 of 32 Implementing Indexes Objectives In this lesson, you will learn to: * Create a clustered index * Create a nonclustered index.
Understanding Databases Lesson 6. Objective Domain Matrix Skills/ConceptsMTA Exam Objectives Understanding Relational Database Concepts Understand relational.
Databases and ADO.NET Programming Right from the Start with Visual Basic.NET 1/e 11.
Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 25 I’m Suffering from Information Overload.
Chapter 24 I’m Suffering from Information Overload (Access Databases) Clearly Visual Basic: Programming with Visual Basic nd Edition.
Session 1 Module 1: Introduction to Data Integrity
Learningcomputer.com SQL Server 2008 –Views, Functions and Stored Procedures.
Chapter 3: Relational Databases
IMS 4212: Constraints & Triggers 1 Dr. Lawrence West, Management Dept., University of Central Florida Stored Procedures in SQL Server.
1 CS 430 Database Theory Winter 2005 Lecture 7: Designing a Database Logical Level.
Chapter 9 Working with Databases. Copyright © 2011 Pearson Addison-Wesley Introduction In this chapter you will learn: – Basic database concepts – How.
SQL Triggers, Functions & Stored Procedures Programming Operations.
SQL Basics Review Reviewing what we’ve learned so far…….
1 Section 1 - Introduction to SQL u SQL is an abbreviation for Structured Query Language. u It is generally pronounced “Sequel” u SQL is a unified language.
Agenda for Today  DATABASE Definition What is DBMS? Types Of Database Most Popular Primary Database  SQL Definition What is SQL Server? Versions Of SQL.
Chapter 12 Introducing Databases. Objectives What a database is and which databases are typically used with ASP.NET pages What SQL is, how it looks, and.
1 SQL SERVER 2005 Express CE-105 SPRING 2007 Engr. Faisal ur Rehman.
Microsoft Visual Basic 2010: Reloaded Fourth Edition
Relational Model.
ADO.NET Framework.
© 2016, Mike Murach & Associates, Inc.
Lesson 10 Working with DATABASE
Entity Framework By: Casey Griffin.
Tonga Institute of Higher Education
Advanced SQL: Views & Triggers
Creating and Managing Database Tables
Chapter 11 Managing Databases with SQL Server 2000
SQL Server Query Design and Optimization Recommendations
Triggers 7/11/2019 See scm-intranet.
Presentation transcript:

ADO.Net TableAdapters and TableAdapterManager Code Camp 2008 Emmet Gray

Introduction Strongly-typed DataSets Based upon DataSet and DataTable classes Based upon DataSet and DataTable classes Wizard based (no need to hand code) Wizard based (no need to hand code) Graphical view of the data Graphical view of the dataBenefits Design-time type checking Design-time type checking Intellisense Intellisense Slight performance increase* Slight performance increase*

Strongly-Typed DataSet Disadvantages Severe code bloat* Severe code bloat* Is often incorrectly used as a substitute for true n-tier “data access layer” Is often incorrectly used as a substitute for true n-tier “data access layer” Use of wizard may cause you to overlook other options such as stored procedures Use of wizard may cause you to overlook other options such as stored procedures * Performance increases may be overshadowed by code bloat

TableAdapter Strongly-typed version of the DataAdapter class The typical way to get data in/out of a strongly-typed DataSet The typical way to get data in/out of a strongly-typed DataSet One “DataAdapter” per table One “DataAdapter” per table Has traditional Fill() and Update() methods Has traditional Fill() and Update() methods Can be expanded with additional methods Can be expanded with additional methods Concepts similar to that of stored procedures Concepts similar to that of stored procedures All queries located in one place All queries located in one place

TableAdapter Disadvantages Tied to the current data provider (i.e. SQL Server) To make a program database “agnostic” you would: Build the DataSet as usual Build the DataSet as usual Remove all TableAdapters Remove all TableAdapters Use the “Data Provider Factory” Use the “Data Provider Factory”

Schema Based All queries in a TableAdapter must return rows based upon the schema associated with the strongly-typed DataTable Joins are allows for filtering (but only columns in the base table are allowed) Joins are allows for filtering (but only columns in the base table are allowed) Exception for scalar queries (that return a single value) Exception for scalar queries (that return a single value) Supports parameterized queries Supports parameterized queries

Queries So how do I handle custom queries that return a different schema? Create a new TableAdapter! Create a new TableAdapter! Also creates a new strongly-typed DataTable Also creates a new strongly-typed DataTable Update() methods Automatically creates the “CommandBuilder” equivalent Insert, Update, Delete commands Automatically creates the “CommandBuilder” equivalent Insert, Update, Delete commands

Database Integrity Constraints upon the data Unique / Primary key Unique / Primary key Foreign Key Foreign KeyRelationships Strongly-typed DataSets support relationships Strongly-typed DataSets support relationships Enforces relationships at run-time Enforces relationships at run-time Detects problems prior to saving to back-end database Detects problems prior to saving to back-end database

Saving the data TableAdapter.Update() method Scans the rows for changes and sends the changes to the back-end database Scans the rows for changes and sends the changes to the back-end database How does the TableAdapter handle updates for queries based upon joins? Poorly… Poorly… You’re are forced to write the update logic by hand You’re are forced to write the update logic by hand

Database Integrity Revisited Since strongly-typed DataSets support relationships, I’m good to go… right? That’s true for your locally cached version of the data That’s true for your locally cached version of the data But you must make sure you update the tables in the back-end database in the correct order! But you must make sure you update the tables in the back-end database in the correct order! Particularly important in foreign-key relationship Particularly important in foreign-key relationship

TableAdapterManager TableAdapterManager New to VS2008 New to VS2008 Automatically scans the relationships and builds an UpdateAll() method that updates the tables in the correct order Automatically scans the relationships and builds an UpdateAll() method that updates the tables in the correct order Not really based upon a “base class” Not really based upon a “base class” Not tied to newer.Net Framework v3.x Not tied to newer.Net Framework v3.x

End Notes TableAdapter Based upon the associated schema of the strongly-typed DataTable Based upon the associated schema of the strongly-typed DataTable Handy place to keep all your queries Handy place to keep all your queries May not be suitable for all ocasions May not be suitable for all ocasionsTableAdapterManager New component to solve the problem of updating the back-end database tables in the correct order New component to solve the problem of updating the back-end database tables in the correct order