ADO.NET Cookbook

Bill Hamilton

  • 出版商: O'Reilly
  • 出版日期: 2003-10-05
  • 售價: $1,710
  • 貴賓價: 9.5$1,625
  • 語言: 英文
  • 頁數: 624
  • 裝訂: Paperback
  • ISBN: 0596004397
  • ISBN-13: 9780596004392
  • 相關分類: .NET
  • 已絕版

買這商品的人也買了...

商品描述

ADO.NET Cookbook is a comprehensive collection of over 150 solutions and best practices for everyday dilemmas. For each problem addressed in the book, there's a solution--a short, focused piece of code that programmers can insert directly into their applications

The diverse solutions presented here will prove invaluable over and over again, for ADO.NET programmers at all levels, from the relatively inexperienced to the most sophisticated.

Table of Contents

Preface

1. Connecting to Data

      1.1 Connecting to an ODBC Data Source

      1.2 Connecting to a Microsoft Excel Workbook

      1.3 Connecting to a Password-Protected Access Database

      1.4 Connecting to a Secured Access Database

      1.5 Connecting to an Access Database from ASP.NET

      1.6 Using an IP Address to Connect to SQL Server

      1.7 Connecting to a Named Instance of SQL Server or Microsoft Data Engine (MSDE)

      1.8 Connecting to SQL Server Using Integrated Security from ASP.NET

      1.9 Connecting to an Oracle Database

      1.10 Connecting to Exchange or Outlook

      1.11 Writing Database-Independent Code

      1.12 Storing Connection Strings

      1.13 Using the Data Link Properties Dialog Box

      1.14 Monitoring Connections

      1.15 Taking Advantage of Connection Pooling

      1.16 Setting Connection Pooling Options

      1.17 Using Transactions with Pooled Connections

      1.18 Changing the Database for an Open Connection

      1.19 Connecting to a Text File

2. Retrieving and Managing Data

      2.1 Retrieving Hierarchical Data into a DataSet

      2.2 Building a DataSet Programmatically

      2.3 Creating a Strongly Typed DataSet

      2.4 Processing a Batch SQL Statement

      2.5 Using a Web Service as a Data Source

      2.6 Accessing Deleted Rows in a DataTable

      2.7 Counting Records in a DataReader

      2.8 Mapping .NET Data Provider Data Types to .NET Framework Data Types

      2.9 Returning an Output Parameter Using a DataReader

      2.10 Raising and Handling Stored Procedure Errors

      2.11 Testing for No Records

      2.12 Retrieving Stored Procedure Return Values Using a DataReader

      2.13 Executing SQL Server User-Defined Scalar Functions

      2.14 Passing Null Values to Parameters

      2.15 Retrieving Update Errors

      2.16 Mapping Table and Column Names Between the Data Source and DataSet

      2.17 Displaying Columns from a Related DataTable

      2.18 Controlling the Names Used in a Strongly Typed DataSet

      2.19 Replacing Null Values in a Strongly Typed DataSet

      2.20 Retrieving Data from an Oracle Package

      2.21 Using Parameterized SQL Statements

      2.22 Querying Data Asynchronously with Message Queuing

3. Searching and Analyzing Data

      3.1 Filtering and Sorting Data

      3.2 Using Expression Columns to Display Calculated Values

      3.3 Determining the Differences in Data Between Two DataSet Objects

      3.4 Navigating Between Parent and Child Records Using a DataRelation

      3.5 Localizing Client-Side Data in a Web Forms Application

      3.6 Combining Data in Tables from Heterogeneous Data Sources

      3.7 Using Expression Columns to Display Aggregate Values

      3.8 Finding Rows in a DataTable

      3.9 Finding Rows in a DataView

      3.10 Selecting the Top n Rows in a DataTable

      3.11 Getting Typed DataRows from DataViews

      3.12 Filtering for Null Values

      3.13 Executing Queries That Use COMPUTE BY

      3.14 Using the Shape Language to Retrieve Hierarchical Data

4. Adding and Modifying Data

      4.1 Using Auto-Incrementing Columns Without Causing Conflicts

      4.2 Getting an Identity Column Value from SQL Server

      4.3 Getting an AutoNumber Value from Microsoft Access

      4.4 Getting a Sequence Value from Oracle

      4.5 Adding Parent/Child Rows with Auto-Incrementing Keys

      4.6 Adding Records with a GUID Primary Key

      4.7 Updating a Data Source with Data from a Different Data Source

      4.8 Updating a Primary Key Value

      4.9 Getting Stored Procedure Parameter Information at Runtime

      4.10 Updating a DataSet with a Many-to-Many Relationship

      4.11 Updating Server Data Using a Web Service

      4.12 Updating Server Data Using .NET Remoting

      4.13 Updating Data Asynchronously Using Message Queuing

      4.14 Overcoming Keyword Conflicts When Using CommandBuilders

5. Copying and Transferring Data

      5.1 Copying Rows from One DataTable to Another

      5.2 Copying Tables from One DataSet to Another

      5.3 Converting a DataReader to a DataSet

      5.4 Serializing Data

      5.5 Deserializing Data

      5.6 Merging Data

      5.7 Transmitting a DataSet Securely

      5.8 Transferring Login Credentials Securely

      5.9 Loading an ADO Recordset into a DataSet

      5.10 Converting a DataSet to an ADO Recordset

      5.11 Exporting the Results of a Query as a String

      5.12 Exporting the Results of a Query to an Array

6. Maintaining Database Integrity

      6.1 Creating a Class That Participates in an Automatic Transaction

      6.2 Using Manual Transactions

      6.3 Nesting Manual Transactions with the SQL Server .NET Data Provider

      6.4 Using ADO.NET and SQL Server DBMS Transactions Together

      6.5 Using a Transaction with a DataAdapter

      6.6 Avoiding Referential Integrity Problems When Updating the Data Source

      6.7 Enforcing Business Rules with Column Expressions

      6.8 Creating Constraints, PrimaryKeys, Relationships Based on Multiple Columns

      6.9 Retrieving Constraints from a SQL Server Database

      6.10 Checking for Concurrency Violations

      6.11 Resolving Data Conflicts

      6.12 Using Transaction Isolation Levels to Protect Data

      6.13 Implementing Pessimistic Concurrency Without Using Database Locks

      6.14 Specifying Locking Hints in a SQL Server Database

7. Binding Data to .NET User Interfaces

      7.1 Binding Simple Data to Web Forms Controls

      7.2 Binding Complex Data to Web Forms Controls

      7.3 Binding Data to a Web Forms DataList

      7.4 Binding Data to a Web Forms DataGrid

      7.5 Editing and Updating Data in a Web Forms DataGrid

      7.6 Synchronizing Master-Detail Web Forms DataGrids

      7.7 Displaying an Image from a Database in a Web Forms Control

      7.8 Displaying an Image from a Database in a Windows Forms Control

      7.9 Binding a Group of Radio Buttons in a Windows Form

      7.10 Creating Custom Columns in a Windows Forms DataGrid

      7.11 Populating a Windows Forms ComboBox

      7.12 Binding a Windows DataGrid to Master-Detail Data

      7.13 Loading a Windows PictureBox with Images Stored by Access as OLE Objects

      7.14 Using a DataView to Control Edits, Deletions, or Additions in Windows Forms

      7.15 Adding Search Capabilities to Windows Forms

      7.16 Dynamically Creating Crystal Reports

      7.17 Using ADO.NET Design-Time Features in Classes Without a GUI

8. Working with XML

      8.1 Using XSD Schema Files to Load and Save a DataSet Structure

      8.2 Saving and Loading a DataSet from XML

      8.3 Synchronizing a DataSet with an XML Document

      8.4 Storing XML to a Database Field

      8.5 Reading XML Data Directly from SQL Server

      8.6 Using XPath to Query Data in a DataSet

      8.7 Transforming a DataSet Using XSLT

      8.8 Creating an XML File That Shows Changes Made to a DataSet

      8.9 Formatting Column Values When Outputting Data as XML

      8.10 Filling a DataSet Using an XML Template Query

      8.11 Using a Single Stored Procedure to Update Multiple Changes to a SQL Server Database

9. Optimizing .NET Data Access

      9.1 Filling a DataSet Asynchronously

      9.2 Canceling an Asynchronous Query

      9.3 Caching Data

      9.4 Improving Paging Performance

      9.5 Performing a Bulk Insert with SQL Server

      9.6 Improving DataReader Performance with Typed Accessors

      9.7 Improving DataReader Performance with Column Ordinals

      9.8 Debugging a SQL Server Stored Procedure

      9.9 Improving Performance While Filling a DataSet

      9.10 Retrieving a Single Value from a Query

      9.11 Reading and Writing Binary Data with SQL Server

      9.12 Reading and Writing Binary Data with Oracle

      9.13 Performing Batch Updates with a DataAdapter

      9.14 Refreshing a DataSet Automatically Using Extended Properties

10. Enumerating and Maintaining Database Objects

      10.1 Listing SQL Servers

      10.2 Retrieving Database Schema Information from SQL Server

      10.3 Retrieving Column Default Values from SQL Server

      10.4 Determining the Length of Columns in a SQL Server Table

      10.5 Counting Records

      10.6 Creating a New Access Database

      10.7 Creating a New SQL Server Database

      10.8 Adding Tables to a Database

      10.9 Getting a SQL Server Query Plan

      10.10 Compacting an Access Database

      10.11 Creating DataSet Relationships from SQL Server Relationships

      10.12 Getting SQL Server Column Metadata Without Returning Data

      10.13 Listing Installed OLE DB Providers

      10.14 Listing Tables in an Access Database

      10.15 Creating a Table in the Database from a DataTable Schema

      10.16 Listing Installed ODBC Drivers

Appendix: Converting from C# to VB Syntax

Index