High Performance Distributed Data

Applications with ASP.NET 1.1

Chapter 1 - The Distributed Application

          What Are Distributed Data Applications?

          Why Do We Need To Distribute?

          Windows to Web.

          Data is dead, long live Data.

          How Can We Do "Distributed" on the Internet?

          Internet Protocols. Internet Clients

          Server Port and Firewall Configurations

          The Elements of a Distributed Application

          Data Stores, server side and client side

          Client Devices and client Applications

          Working with "Rich" Clients. Working with "Down-level" Clients

          Processing and Presenting Information

          A Simple 3-tier Design. A More Realistic 3-tier Design

          Moving to n-tier Designs. A More Realistic n-tier Design

          Framework Resources for the Middle Tier

          Understanding ADO.NET

          About "Relational" Data Access

          Classic ADO via Interop. Classic ADO Techniques

          The ADO.NET Data Access Classes.

          The .NET Data Providers

          Connected Data Access - the DataReader

          Disconnected Data Access - the DataSet

          The DataAdapter Object, Pushing Changes Back to the Data Store

          Understanding System.Xml

          Representing Data and Information

          Schemas and DTDs, Unstructured Information

          The W3C Interface Recommendations

          An Overview of the System.Xml Namespace, the System.Xml Classes

          The XML "Document" Objects

          The XML "Navigator" Object

          XML and Relational Data Synchronization

          The XML "Writer" and "Reader" Objects

          The XML "Validation" Objects

          The XSL "Transformation" Object

          Data Access and the n-tier Model.

          What is The Data Being Used For?

          Do We Need to Remote the Data?

          Serialization and the System.Runtime.Remoting Classes

          Are We Just Displaying the Data?

          Some n-tier Data Access Scenarios

          Displaying Data - Doing It All On The Server

          Expanding the Middle Tier, Moving Processing to the Client

          Getting Updates Back to the Server, HTML Forms and Query Strings

          Client-side Components, Client Side Executables and Services


Chapter 2 - Data Access Components

          Data Access Components

          Different Types of "Component"

          .NET Components

          Building .NET Components

          Using a .NET Component

          COM and COM+ Components

          User Controls

          Using a User Control

          Include Files

          Server Controls

          Accessing and Exposing Data

          Delivering Data to Rich Clients

          Managing Data for Down-level Clients

          Displaying XML Data

          The DataSet Object

          The Structure of the DataSet Object

          The DataTable Object

          Filling a DataSet with a DataAdapter

          Table and Column Mappings

          When Should I Use a DataSet?

          Relational Data Access Component Examples

          Setting Up the Examples

          Accessing and Returning Relational Data

          Returning a DataReader Reference

          The SupplierList Data Access Component

          The GetSuppliersDataReader Method

          Displaying the Results

          Returning a DataSet Object

          The GetSuppliersDataSet Method

          Returning a Custom Array Reference

          Filling the Array

          Displaying the Results

          Returning an ArrayList Reference

          Filling the ArrayList

          Displaying the Results

          Returning an XML String

          Displaying the Results

          The Resulting XML and the XSL Stylesheet

          Returning an XmlDocument Object

          Displaying the Results

          Returning XML via SQLXML from SQL Server

          The GetSuppliersSqlXml Method

          Displaying the Results

          Returning Related Tables in a DataSet Object

          The Data Access Component and Stored Procedures

          The GetOrdersByCustomerDataSet Method

          Filling the Tables

          Creating the Relationship Between the Tables

          Displaying the Results in Tables

          Using the Data Relationship Information

          Searching for Customers By Name


Chapter 3 - Accessing XML Documents

          Accessing XML Documents

          XML Data Access Component Examples

          Accessing and Returning Relational Data

          The SupplierListXml Data Access Component

          Returning an XmlTextReader Reference

          Displaying the Results

          The Page_Load Event Handler

          Parsing an XML Document

          Returning an XmlValidatingReader Reference

          Creating and Initializing an XmlValidatingReader Object

          Catching Validation Events

          Displaying the Results of the GetSuppliersValidatingReader Method

          Returning a DataSet Object

          Displaying the Results

          Returning a Custom Array Reference

          Using the XPathNavigator and XPathNodeIterator Objects

          Building the Array

          Displaying the Results

          Returning an ArrayList Reference

          Displaying the Results

          Returning an XML String

          Displaying the Results

          Returning an XmlDocument Object

          Displaying the Results

          Returning an XPathDocument Object

          Displaying the Results


Chapter 4 - The Application Plumbing

          The Application Plumbing

          Overview of Client-side Techniques

          Available Client-side Programming Techniques

          Making a Choice on Client Support

          Providing Alternative Client Support

          Adapting Content for Individual Clients

          Using Client "Categories"

          Our Chosen Categories

          Choosing Categories Based on Actual Client Requests

          Remoting Data to the Client

          Remoting Relational Data to the Client

          Remote Data Services with Relational Data

          The Text Data Control

          Running the .NET Framework on the Client

          Using a Web Service

          Remoting XML Data to the Client

          Client-side XML Parsers

          The MSXML Parser

          MSXML Parser Versions

          Running the .NET Framework on the Client

          The Basics of .NET Remoting

          Aspects of .NET Remoting

          Object Marshalling

          Marshal By Value - Automatic

          Marshal By Value - Custom

          Invoking Serialization

          Marshal By Reference

          Marshal By Object or Marshal By Reference?

          Activation and Lifetime



          Hosting the server in IIS


          Using ASP.NET Sessions

          Sessions Configuration in ASP.NET

          Disabling Session Support

          Sessions and Web Farms

          Checking for Session Support

          Munging URLs for Session Support

          Client Detection Example

          Overview of the Process

          Detecting the Client Type

          Detecting Non-HTML Client Devices

          Using the Mobile Internet Toolkit

          The Client Type Detection Code

          Determining the Type for HTML Clients

          The default.aspx Page

          Detection Errors and Unsupported Clients

          Checking for Client-side Scripting Support

          Redirecting The Client If Scripting Is Enabled

          The Device-Specific "Home" Pages

          Displaying the Results

          The WML-specific "Home" Page

          Getting the Capabilities Information

          Viewing the Results

          Internet Explorer 6.0

          WML Devices - the Nokia Phone Simulator


Chapter 5 - Working with Down-level Clients

          Working with Down-level Clients

          A Multiple-Client Order List Application

          The User Interface

          Detecting the Client Type

          Checking for Client-Side Scripting Support

          Session Support

          The Data Access Tier

          Maximizing Efficiency through Caching

          The Order List Application - HTML Version

          The Outline Process

          Searching for Customers

          The HTML Form Controls

          Displaying a List of Customers

          Showing the Help Text

          Calling the Data Access Component

          Performing the Customer Search

          Fetching and Displaying the Results

          The DataGrid to Display the Customer List

          Defining the Columns in the DataGrid

          Handling Paging in the DataGrid

          Displaying a List of Orders

          The Order List Frameset Page

          Getting the Data from the Session or Server

          The GetDataSetFromSessionOrServer Function

          The DataGrid to Display the Order List

          Using a "Template" Column

          The Page_Load Event Handler

          Displaying the Order List

          Displaying the Order Details

          The Declaration of the DataGrid and Labels

          The ASP.NET Code for the Page

          Getting the DataSet from the Server or Session

          The ShowOrderLines Routine

          Calculating the Order Total and Displaying the Details

          The Order List Application - "Mobile" Version

          The Outline Process

          Fetching Data from the Server

          Fetching the Customer List

          Fetching the Orders Data

          Massaging the DataSet

          The Mobile Page Content

          Adding Style to the Output

          The Mobile Stylesheet for our Application

          Setting the Search Type

          Specifying the Search String

          The Code in the SetSearchType Event Handler

          Showing the Customer List

          The Code in the GetCustomers Event Handler

          Listing the Orders for the Selected Customer

          The Code in the GetOrders Event Handler

          Displaying the Order Details

          The Code in the ShowOrderDetail Event Handler


Chapter 6 - Working with Rich Clients

          Working with Rich Clients

          Working with XML

          Why XSL and XSLT?

          Exposing and Delivering XML

          Using XML in IE5 and Above

          Building the Middle Tier

          Fetching the Customer List

          The Page_Load Event Handler

          Fetching the Order List

          The Page_Load Event Handler

          Nested XML Output from a DataSet

          Selecting a Customer

          The HTML Page Content

          Access Keys and Button Captions

          The Help Text and Results Display Area

          Loading the XML Customers List

          Checking the ReadyState

          Displaying the Help Text

          Finding and Displaying Customer Details

          Using an XSLT Stylesheet

          Creating the XPath Statements

          The XSLT Stylesheet

          Performing the Transformation

          The Client-side doSearch Function

          Sorting and Paging the Customer List

          Selecting an Order

          The HTML Page Content

          Loading the XML Orders List

          Finding and Displaying the Order Details

          Processing the XSLT Stylesheet

          The XSLT Stylesheet for the Order List

          Viewing Order Details

          Extracting the Order Details

          Using Web Services in IE5 and Above

          Looking at the Customer-Data Web Service

          Testing a Web Service

          Building the Middle Tier

          Storing Application Settings in web.config

          The GetCustomers Method

          The GetOrders Method

          The IE5 WebService Behavior

          Opening and Using a Web Service

          Accessing the Response from the Web Service

          Using the XML Data in our Application.

          A Hypertext Application Example

          Running the Example Hypertext Application

          Loading the XML Data

          Building the Middle Tier

          The HTA Page Content

          Downloading the Data

          The loadXMLDocument Function

          The saveLocalXML Function

          The refreshData Function

          Implementing Hyperlinks in HTA Pages

          Selecting an Order

          Working with Delimited Text Data

          Remember the TDC?

          Building the Middle Tier

          The Middle-Tier Component

          Creating the Customer List Delimited String

          Creating the Order List Delimited String

          Creating the Customer List Delimited String

          Iterate or Transform?

          Selecting a Customer

          Declaring the Tabular Data Control

          Using the ReadyStateChange Event

          The Data-Bound Table

          Paging the Table Rows

          The DoSearch Subroutine

          Filtering the Data

          Displaying the Results

          Selecting and Viewing an Order

          Fetching the Data from the Server

          Setting the Customer ID Client-side

          The Data-Bound Tables

          The ShowOrderDetail Subroutine

          Specifying Currency and Percentage Formats.

          Client-side Data Binding with XML Anyone?


Chapter 7 - .NET Remoting to Clients

          All about .NET remoting and Serialization

          Remoting Data

          Remoting Forms

          Remoting Executables/DLLs

          Example from Customer Orders application

          Using Windows Forms application to display data

Chapter 8 - Updating Data in Down-level Clients

          Updating Data in Down-level Clients

          Updating Data Stores - An Overview

          Making the Process As Efficient As Possible

          Caching Data Updates

          Maintaining a Separate Cached Copy of the Data

          Measuring the Results and Providing Feedback

          Controlling Access to Protect the Data

          Controlling Concurrent Data Updates

          Why Concurrency Errors Arise

          Concurrency Issues in a Disconnected Application

          Are we Connected, Disconnected or Fully Disconnected?

          Data Update Techniques in .NET

          Executing Updates with a Command Object

          The ExecuteNonQuery Method

          Returning Single Values from a Stored Procedure

          The DataSet Update Feature

          Using a CommandBuilder to Create Command Objects

          Using Custom Stored Procedures to Update Data

          Using Transactions While Updating Data

          Database Transactions in Stored Procedures

          Connection-Based Transactions

          Connection-Based Transactions with a DataSet Update

          Managing Concurrency While Updating

          Minimizing Concurrency Errors

          Detecting Concurrency Errors

          Checking the Number of Rows Affected

          Concurrency Management in a DataSet Object

          Data Update Example for HTML 3.2 Clients

          An Overview of the Application

          Displaying the Order Details

          Editing the Order Details

          Displaying and Editing Orders

          The Data Access Tier

          The GetOrderDetails Function

          The HTML Page Declaration

          The ItemTemplate for the DataList

          The EditItemTemplate for the DataList

          Storing the Original Values for the Columns

          The FooterTemplate for the DataList

          Displaying a List of Orders

          The ShowOrders Routine

          The OnItemDataBound Event Handler

          Showing and Hiding Controls

          Filling and Selecting Items in a DropDownList Control

          Switching To and From Edit Mode

          Handling ItemCommand Events

          Handling the "New Order" Button

          Setting the Freight Cost

          Inserting a New Order

          The Data Access Tier InsertNewOrder Method

          The ASP.NET Page InsertNewOrder Method

          Updating the Order Details

          The Data Access Tier SingleRowOrderUpdate Method

          The ASP.NET Page DoItemUpdate Method

          Parsing the User's Values

          Calling the Data Access Tier Method

          Deleting an Order

          The Data Access Tier SingleRowOrderDelete Method

          The ASP.NET Page DoItemDelete Method

          Displaying and Editing the Order Contents

          The HTML Page Declaration

          The Columns for the DataGrid Control

          Using Bound Columns

          Using Command Columns

          Displaying a List of Order Lines

          The ShowOrderLines Routine

          Displaying the "Add Product" Controls

          Displaying the DataGrid and Order Total

          Editing the Order Lines

          Adding a New Order Line

          Selecting the New Order Line Row in the DataGrid

          Updating and Deleting Existing Order Lines

          Data Update Example for Mobile Devices

          The Application Design

          Viewing the Application

          Viewing the Application in a Cellular 'Phone


Chapter 9 - Updating Remote Cached Data

          Updating Remote Cached Data

          Reviewing the Architecture

          Caching Updates on the Client

          Getting Updates Back to the Server

          Loading a DataSet

          Reading an XML Document into a DataSet

          An Example of Reading an XML Document and Schema

          Displaying Current and Original Column Values

          Displaying the DataSet Contents

          Populating the Original Values

          Validating XML While Reading into a DataSet

          Reading an XML DiffGram into a DataSet

          An Example of Reading an XML Diffgram

          Filling a DataSet Using Code

          An Example of Building a DataSet using Code

          Reading Non-standard Data Formats

          Filling a DataSet Using the Fill Method

          Executing the Update Process

          Providing Feedback from the Update Process

          What Do We Want From The Process?

          Can the ADO.NET DataSet Do What We Want?

          What Are the Original Values?

          The Update Process In Detail

          The Result

          A Data Update Process Example

          How it Works

          The Page_Load Event Handler

          Specifying the Primary Key for the Table

          Editing Some of the Row Values

          Simulating a Concurrent Edit

          Marshaling the Changes into a new DataSet

          The GetChanges Method

          Updating the Data Store

          Handling the RowUpdated Event

          Fetching the Underlying Values from the Database

          Are We Refreshing or Filling?

          Merging the Two DataSets

          Extracting Just the Error Rows

          Using the HasErrors property

          Summarizing the Process

          The AcceptChangesDuringFill Property


Chapter 10 - Components for Updating Data

          The UpdateDataSet Component

          Enabling Tracing from Within a Component

          Writing to the Trace Object

          The Common Methods in our Component

          Managing IDENTITY Columns for Inserted Rows

          Using GUIDs Or Random Values for the Primary Key

          Inserting IDENTITY Values

          Reading the IDENTITY Value and Updating the Columns

          Interacting with the Update Method

          The Class-Level Variables

          Handling the RowUpdating Event

          Accessing the IDENTITY Column Value

          The OrdersInsert Stored Procedure

          Handling the RowUpdated Event

          Using the Status Property

          Remote Row Inserts Summary

          The UpdateAllOrderDetails Method

          The GetChanges Stage

          The Update Stage

          Setting the Update Event Handlers and Updating the Orders Table

          Updating the Order Details Rows

          The Refresh Stage

          The Merge Stage

          Checking for Errors

          Creating the Parameterized Command Objects

          The Stored Procedures for the Orders Table

          The OrdersDelete Stored Procedure

          The OrdersInsert Stored Procedure

          The GetOrdersCommand Function

          The Stored Procedures for the Order Details Table

          The OrderLinesInsert Stored Procedure

          The OrderLinesDelete Stored Procedure

          The GetOrderLinesCommand Function

          Using the UpdateDataSet Component

          The update-orders-demo.aspx Page

          Filling the DataSet

          Editing Some Row Values

          Changing the Underlying Database Values Concurrently

          Performing the Update

          Displaying The Update Errors

          Deleting The New Rows We Added

          Viewing The Trace Information

          Returning Only The Error Rows


Chapter 11 - Rich Client Update Applications

          Rich Client Update Applications

          An Overview of the Application

          The Process in Outline

          Checking for Concurrency Errors

          The Middle-Tier ASP.NET Page

          Getting the Data from the Data Access Tier

          Exposing the Data to the Client

          Loading the Diffgrams on the Client

          Loading the Orders Data

          Loading the Shippers Data

          Loading the Products Data

          Editing a .NET DataSet Diffgram

          Viewing the Updated Diffgram

          Displaying the Contents of the DataSet

          Displaying the Diffgram Contents

          The Updated Diffgram Format

          The Update Rules for a DataSet Diffgram

          Custom Functions for Manipulating the Diffgram

          Copying Nodes to the <diffgr:before> Section

          Using the appendChild and cloneNode Methods

          The edit-orders.aspx Page Code and HTML

          Creating the List of Orders

          The List of Orders

          Posting the Updated Diffgram to the Server

          The Button to Save Changes to the Server

          Sending the Diffgram via XMLHTTP

          Marshaling Changes Rows

          Displaying Details of the Selected Order

          The HTML Controls to Display the Order Details

          Specifying the Tab Index and Shortcut Keys

          The Code to Display the Order Details

          Detecting NULL ShippedDate Values

          Populating the Controls on the Page

          Getting and Displaying a List of Order Lines

          Calculating and Displaying the Order Total

          Creating the List of Order Lines

          The Stylesheet for the Order Lines List

          Creating the Update Line and Delete Line Buttons

          It's Time to Talk Dirty

          Handling the Document Object OnUnload Event

          Updating the Orders Diffgram

          Adding a New Order

          Setting Default Values for New Order Rows

          Validating the Values for New Order Rows

          Creating a New Orders Node

          Adding the Child Nodes

          The Name and Address Details

          Adding the New Node to the Diffgram

          Deleting an Existing Order

          Modifying an Existing Order

          Setting the Updated RequiredDate Value

          Setting the Updated ShippedDate Value

          Setting the Rest of the Node Values

          Updating an Order Details Node

          Validating the User's Input

          Calculating the Line Total

          The updateOrder Function

          Adding a New Order Line

          Setting the Child Node Values

          The addOrderLine Function

          Creating the New Order Details Node

          Deleting an Existing Order Line

          Modifying an Existing Order Line


Chapter 12 - Reconciling Update Errors

          Reconciling Update Errors

          Reconciling Update Errors in Overview

          A Summary of the Process

          The Error Reporting and Reconciliation Process

          Editing the DataSet After Update Errors Have Occured

          Displaying the Update Errors for Reconciliation

          Following a Successful Update

          Displaying Trace Information

          The Reconciliation Process in Detail

          The reconcile-changes.aspx Page

          The HTML Form and Hyperlinks

          Collecting the Posted Values

          Loading the Edited Diffgram

          Working Round the "Empty Diffgram" Issue

          Loading the DataSet

          Removing the Extra Calculated Column

          Working Round the "Extra Rows" Issue

          Editing the DataSet Contents for a PostBack

          Checking for Error Rows Before Attempting the Update

          Updating the Database from the DataSet

          Checking Errors After the Update Process

          Getting a Diffgram as a String from a DataSet

          Displaying the Errors and Reconciliation Options

          The Display for Modified Rows

          The Display for Added Rows

          The Display for Deleted Rows

          The Code for the GetDisplayString Function

          Building the HTML Table

          Displaying the Proposed and Existing Values

          Displaying the HTML Checkbox Controls

          Editing the Values in the DataSet Tables

          The Process in Outline

          The Code for the EditTable Routine

          Removing Added and Deleted Rows

          Editing Modified Rows

          And Round We Go Again

          Rich Client Updates Via a Web Service

          The Issues and Workarounds

          The Middle-Tier Web Service Component

          Loading the Diffgram into a DataSet

          Updating the Database

          The Web Service Client Application

          Loading the Data Via the Web Service

          Handling the Web Service Behavior's DataLoaded Event

          Handling the MSXML onreadystatechange Event

          Filling the Shippers and Products Drop-down Lists

          Extracting the Diffgram

          Sending Data Back to the Server Via the Web Service

          Modifying the Diffgram

          HTML-Encoding the String

          Calling the Web Service UpdateAllOrders Method

          Handling the Returned "Errors" DataSet

          A Diffgram with Row Errors

          Counting and Displaying the Row Errors

          If There Are No Errors

          Showing the Original Row Values

          A Few Other Differences

          Other Rich Client Update Techniques

          Rich Client Updates Using Delimited Data

          Some Possible Solutions

          Setting the Current and Original Row Values

          Marshalling the Changed Rows

          Caching the Original Rows on the Server

          Hypertext Application Updates

          Some Possible Solutions

          Marshalling the Changed Rows

          Install the .NET Frameworks Instead


Chapter 13 - Updating Data via .NET Remoting

          The Windows Forms Application

          Using Different Web Services

          The Orders Method

          The Lookups Method

          The UpdateOrders Method

          The New Editable Orders Form

          DataGrids and TableStyles

          Windows Forms Data binding

          The CurrencyManager Object

          The BindingContext Object

          Binding the DataGrid Control

          Binding a Datagrid to Hierachical Data

          Binding TextBox Controls

          Binding ComboBox Controls

          The DataBindings Collection

          Maintaining the Current Row

          Handling the PositionChanged Event

          The Code so Far

          Handling Data Changes

          Adding Rows

          Deleting Rows

          Cancelling Edits

          Flushing Changes to the Database

          Back From the Error Form

          Handling Concurrency Conflicts

          The ErrorProvider Object

          The Error Handling Form

          Identifying Errors

          Setting Column Errors

          Extract the Errors

          Changing the View

          Changing the Parent View

          Changing the Child View

          Correcting Errors

          Correcting the Error

          Handling Lookup Values

          Clearing the Current Error


          Handling Deleted Rows

          Correcting Errors in Deleted Rows

          Saving the Corrected Data

          The Application in Practice