, APress Beginning C# 2008 Databases From Novice to Professional, 

APress Beginning C# 2008 Databases ...

APress Beginning C# 2008 Databases From Novice to Professional,
[ Pobierz całość w formacie PDF ]
Beginning C#
2008 Databases
From Novice
to Professional
Vidya Vrat Agarwal and James Huddleston
Ranga Raghuram, Syed Fahad Gilani,
Jacob Hammer Pedersen, and Jon Reid
Beginning C# 2008 Databases: From Novice to Professional
Copyright © 2008 by Vidya Vrat Agarwal, James Huddleston, Ranga Raghuram, Syed Fahad Gilani,
Jacob Hammer Pedersen, and Jon Reid
All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means,
electronic or mechanical, including photocopying, recording, or by any information storage or retrieval
system, without the prior written permission of the copyright owner and the publisher.
ISBN-13 (pbk): 978-1-59059-900-6
ISBN-10 (pbk): 1-59059-900-4
ISBN-13 (electronic): 978-1-4302-0450-3
ISBN-10 (electronic): 1-4302-0450-8
Printed and bound in the United States of America 9 8 7 6 5 4 3 2 1
Trademarked names may appear in this book. Rather than use a trademark symbol with every occurrence
of a trademarked name, we use the names only in an editorial fashion and to the benefit of the trademark
owner, with no intention of infringement of the trademark.
Lead Editor: Jonathan Hassell
Technical Reviewer: Fabio Claudio Ferracchiati
Editorial Board: Steve Anglin, Ewan Buckingham, Tony Campbell, Gary Cornell, Jonathan Gennick,
Kevin Goff, Jonathan Hassell, Matthew Moodie, Joseph Ottinger, Jeffrey Pepper, Ben Renow-Clarke,
Dominic Shakeshaft, Matt Wade, Tom Welsh
Project Manager: Beth Christmas
Copy Editor: Ami Knox
Associate Production Director: Kari Brooks-Copony
Production Editor: Ellie Fountain
Compositor: Linda Weidemann, Wolf Creek Press
Proofreader: Nancy Sixsmith
Indexer: Broccoli Information Management
Artist: April Milne
Cover Designer: Kurt Krames
Manufacturing Director: Tom Debolski
Distributed to the book trade worldwide by Springer-Verlag New York, Inc., 233 Spring Street, 6th Floor,
New York, NY 10013. Phone 1-800-SPRINGER, fax 201-348-4505, e-mail
orders-ny@springer-sbm.com
,
or visit
.
For information on translations, please contact Apress directly at 2855 Telegraph Avenue, Suite 600,
Berkeley, CA 94705. Phone 510-549-5930, fax 510-549-5939, e-mail
info@apress.com
, or visit
www.apress.com
.
The information in this book is distributed on an “as is” basis, without warranty. Although every pre-
caution has been taken in the preparation of this work, neither the author(s) nor Apress shall have any
liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly
or indirectly by the information contained in this work.
The source code for this book is available to readers at
. You will need to answer
questions pertaining to this book in order to successfully download the code.
In loving memory of James E. Huddleston
( June 7, 1951–February 25, 2007)
&
To my sweet little daughter, Pearly,
and beloved wife, Rupali
—Vidya Vrat Agarwal
Contents at a Glance
About the Authors
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxi
About the Technical Reviewer
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxiii
Acknowledgments
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxv
Introduction
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxvii
n
CHAPTER 1
Getting Your Tools
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
n
CHAPTER 2
Getting to Know Your Tools
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
n
CHAPTER 3
Getting to Know Relational Databases
. . . . . . . . . . . . . . . . . . . . . . . . . . 27
n
CHAPTER 4
Writing Database Queries
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
n
CHAPTER 5
Manipulating Database Data
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
n
CHAPTER 6
Using Stored Procedures
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
n
CHAPTER 7
Using XML
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
n
CHAPTER 8
Understanding Transactions
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135
n
CHAPTER 9
Getting to Know ADO.NET
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
n
CHAPTER 10
Making Connections
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189
n
CHAPTER 11
Executing Commands
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209
n
CHAPTER 12
Using Data Readers
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235
n
CHAPTER 13
Using Datasets and Data Adapters
. . . . . . . . . . . . . . . . . . . . . . . . . . . . 265
n
CHAPTER 14
Building Windows Forms Applications
. . . . . . . . . . . . . . . . . . . . . . . . . 321
n
CHAPTER 15
Building ASP.NET Applications
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349
n
CHAPTER 16
Handling Exceptions
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 369
n
CHAPTER 17
Working with Events
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 391
n
CHAPTER 18
Working with Text and Binary Data
. . . . . . . . . . . . . . . . . . . . . . . . . . . . 403
n
CHAPTER 19
Using LINQ
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 431
n
CHAPTER 20
Using ADO.NET 3.5
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 449
n
INDEX
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 467
v
Contents
About the Authors
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxi
About the Technical Reviewer
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxiii
Acknowledgments
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxv
Introduction
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxvii
n
CHAPTER 1
Getting Your Tools
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Obtaining Visual Studio 2008
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Installing SQL Server Management Studio Express
. . . . . . . . . . . . . . . . . . . . 3
Installing the Northwind Sample Database
. . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Installing the Northwind Creation Script
. . . . . . . . . . . . . . . . . . . . . . . . 5
Creating the Northwind Sample Database
. . . . . . . . . . . . . . . . . . . . . . 6
Installing the AdventureWorks Sample Database
. . . . . . . . . . . . . . . . . . . . . 9
Installing the AdventureWorks Creation Script
. . . . . . . . . . . . . . . . . . . 9
Creating the AdventureWorks Sample Database
. . . . . . . . . . . . . . . . 10
Summary
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
n
CHAPTER 2
Getting to Know Your Tools
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Microsoft .NET Framework Versions and the Green Bit and
Red Bit Assembly Model
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Using Microsoft Visual Studio 2008
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Try It Out: Creating a Simple Console Application Project
Using Visual Studio 2008
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
How It Works
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
Using SQL Server Management Studio Express
. . . . . . . . . . . . . . . . . . . . . . 22
Summary
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
vii
[ Pobierz całość w formacie PDF ]
  • zanotowane.pl
  • doc.pisz.pl
  • pdf.pisz.pl
  • dodatni.htw.pl