Presentation is loading. Please wait.

Presentation is loading. Please wait.

DAT 390 Advanced ADO.NET Programming Techniques Jackie Goldstein Renaissance Computer Systems

Similar presentations


Presentation on theme: "DAT 390 Advanced ADO.NET Programming Techniques Jackie Goldstein Renaissance Computer Systems"— Presentation transcript:

1 DAT 390 Advanced ADO.NET Programming Techniques Jackie Goldstein Renaissance Computer Systems jackie@renaissance.co.il

2

3 Jackie Goldstein… General Manager of Renaissance Computer Systems Consulting, Training, & Development, with Microsoft Tools & Technologies Author of “Database Access with Visual Basic.Net” (ISBN 0-67232-3435, Addison-Wesley) MSDN Regional Director for Israel Founder and monthly host of IVBUG (Israel Visual Basic User Group) Speaker at local & international developer conferences: Microsoft Developer Days, TechEd, VSLive!, VBITS, VB DevCon, SQL2TheMax Selected as SME (Subject Matter Expert) to help develop/review content for DevDays 2000 and DevDays 2001 with Microsoft team in Redmond

4 Session Topics “Here You Come Again” A Quick Review “One, Twice, Three Times a Lady” 3 Ways to Configure the DataAdapter “I Can See Clearly Now” Data Views and DataRowViewState “Love Will Keep Us Together” Multi-Table Reads and Updates “We Can Work it Out” Concurrency Conflicts Questions and Summary

5 Data In The.NET Platform.NET Data Provider DataReader Command Connection Sync Controls, Designers, Code-gen, etc DataSet XmlReader XmlText-ReaderXmlNode-Reader XSL/T, X-Path, Validation, etc XmlData- Document Data-Adapter

6 Points to Note in ADO.NET vs. ADO Separation between connected data access model and disconnected programming model No CursorType, CursorLocation, or LockType ADO Recordset functionality is split into smaller, specific objects, e.g. DataReader, DataTable, Command ADO.NET allows manipulation of XML data, not just XML as I/O format

7 DataSet Object DataSet DataTable DataTable DataRow DataColumn Relations Constraints XML Schema

8 DataAdapter Object DataAdapter SelectCommand InsertCommand UpdateCommand DeleteCommand TableMappings Database DataSet

9 “One, Twice, Three Times a Lady” 3 Ways to Configure the DataAdapter The CommandBuilder Object Explicit Code The DataAdapter Configuration Wizard demo demo

10 “I Can See Clearly Now” DataViews and DataRowViewState Multiple simultaneous views of the same DataSet data, filtered and sorted byDataRowViewState demo demo

11 “Love Will Keep Us Together” Multi-Table Reads and Updates The standard methods of generating update command for the DataAdapter (CommandBuilder and DataAdapter Configuration Wizard) support only single-table updates How do I do multi-table reads and updates ?

12 “Love Will Keep Us Together” Multi-Table Reads and Updates Use Batch SQL / Stored Procedures to load multiple DataSet tables in one server round-trip Use ExecuteXmlReader to fetch hierarchical data and load into DataSet Update multiple tables using a Stored Procedure Issue multiple update commands by calling the Update methods of the individual DataAdapters

13 “Love Will Keep Us Together” Multi-Table Updates Generally update related tables in the following order: 1. Child Table: Delete Records 2. Parent Table: Insert, Update, and Delete records 3. Child Table: Insert and Update records

14 “ Love Will Keep Us Together” Multi-Table Reads and Updates demo demo Read multiple tables into the DataSet in a single round-trip to the database server Update the database with changes to multiple tables

15 “We Can Work it Out” Concurrency Conflicts Why Optimistic Locking ? Conflict Detection Conflict Resolution DataSet maintains 3 views of field value: Original, Current, and Proposed (during edit) Can force changes, reject changes, or reject changes and reload data from source

16 What defines a conflict ? ADO 2.X – Dynamic Property “Update Criteria” adCriteriaUpdCols (default) adCriteriaAllCols adCriteriaTimeStamp adCriteriaKey ADO.NET Auto-generated commands include PK and all fields in UPDATE and DELETE statements Developer can specify own custom SQL statements (e.g. if 2 of the 5 columns were modified)

17 Differences in ADO.NET Can be automatically generated (but with limitations) Greater flexibility in defining what constitutes a conflict (see previous slide) A little more manual code required Passing different versions of columns Retrieving current database values More flexibility in handling batches with one or more conflicts

18 “We Can Work it Out” Concurrency Conflicts demo demo Detecting and resolving concurrency conflicts

19 Summary The DataSet (and its associated objects) provides very flexible data manipulation The DataAdapter provides flexible and powerful batch update support The DataView allows multiple simultaneous views of the same DataSet data Dig into the details !

20 Community Resources http://www.microsoft.com/communities/default.mspx Most Valuable Professional (MVP) http://www.mvp.support.microsoft.com/ Newsgroups Converse online with Microsoft Newsgroups, including Worldwide http://www.microsoft.com/communities/newsgroups/default.mspx User Groups Meet and learn with your peers http://www.microsoft.com/communities/usergroups/default.mspx

21 Ask The Experts Get Your Questions Answered I will be in the Microsoft Ask The Experts area during the following hours: Wednesday13:00 – 14:00 Thursday13:00 – 14:00

22 evaluations evaluations

23 Questions?

24 Titles and Artists “Here You Come Again” Dolly Parton “One, Twice, Three Times a Lady” The Commodores “I Can See Clearly Now” Johnny Nash “Love Will Keep Us Together” The Captain & Tennille “We Can Work it Out” The Beatles

25 © 2003 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS OR IMPLIED, IN THIS SUMMARY.


Download ppt "DAT 390 Advanced ADO.NET Programming Techniques Jackie Goldstein Renaissance Computer Systems"

Similar presentations


Ads by Google