Beginning VB .NET 1.1 Databases.pdf

(7698 KB) Pobierz
674523235 UNPDF
Beginning VB .NET 1.1
Databases: From Novice
to Professional
DAN MAHARRY, JAMES HUDDLESTON, RANGA RAGHURAM, SCOTT ALLEN,
SYED FAHAD GILANI, JACOB HAMMER PEDERSEN, JON REID
674523235.001.png
Beginning VB .NET 1.1 Databases: From Novice to Professional
Copyright © 2005 by Dan Maharry, James Huddleston, Ranga Raghuram, Scott Allen, Syed Fahad Gilani,
Jacob Hammer Pedersen, 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 (pbk): 1-59059-358-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: Dominic Shakeshaft
Editorial Board: Steve Anglin, Dan Appleman, Ewan Buckingham, Gary Cornell, Tony Davis, Jason Gilmore,
Jonathan Hassell, Chris Mills, Dominic Shakeshaft, Jim Sumser
Project Manager: Kylie Johnston
Copy Edit Manager: Nicole LeClerc
Copy Editor: Kim Wimpsett
Production Manager: Kari Brooks
Production Editor: Katie Stence
Compositor: Susan Glinert
Proofreader: Liz Welch
Indexer: John Collin
Artist: April Milne
Cover Designer: Kurt Krames
Manufacturing Manager: Tom Debolski
Distributed to the book trade in the United States by Springer-Verlag New York, LLC, 233 Spring Street,
6th Floor, New York, NY 10013 and outside the United States by Springer-Verlag GmbH & Co. KG,
Tiergartenstr. 17, 69112 Heidelberg, Germany.
In the United States: phone 1-800-SPRINGER, e-mail orders@springer-ny.com , or visit
http://www.springer-ny.com . Outside the United States: fax +49 6221 345229, e-mail orders@springer.de ,
or visit http://www.springer.de .
For information on translations, please contact Apress directly at 2560 Ninth Street, Suite 219, Berkeley, CA
94710. Phone 510-549-5930, fax 510-549-5939, e-mail info@apress.com , or visit http://www.apress.com .
The information in this book is distributed on an “as is” basis, without warranty. Although every precaution
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 http://www.apress.com in the Downloads section.
This book is for Jane. Her ring fits through mine, but she is my perfect fit.
—Dan Maharry
Contents at a Glance
About the Authors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xix
Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxi
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxiii
CHAPTER 1
Installing MSDE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
CHAPTER 2
Creating a Simple Database Application . . . . . . . . . . . . . . . . . . . . . . . 13
CHAPTER 3
Introducing SQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
CHAPTER 4
What’s ADO.NET? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
CHAPTER 5
Creating Connections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
CHAPTER 6
Introducing Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
CHAPTER 7
Introducing Data Readers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143
CHAPTER 8
Introducing Datasets and Data Adapters . . . . . . . . . . . . . . . . . . . . . 169
CHAPTER 9
Building Windows Forms Applications . . . . . . . . . . . . . . . . . . . . . . . 211
CHAPTER 10
Using ASP.NET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237
CHAPTER 11
Validating Web User Input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281
CHAPTER 12
Working with Tables and Relationships . . . . . . . . . . . . . . . . . . . . . . 303
CHAPTER 13
Learning More About Queries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 329
CHAPTER 14
Understanding Views and Stored Procedures . . . . . . . . . . . . . . . . . 365
CHAPTER 15
Using Indexes and Constraints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 401
CHAPTER 16
Securing Your Database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 425
CHAPTER 17
Using XML and ADO.NET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 451
CHAPTER 18
Handling Exceptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 469
CHAPTER 19
Using Transactions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 489
CHAPTER 20
Working with ADO.NET Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 503
CHAPTER 21
Working with Text and Binary Data . . . . . . . . . . . . . . . . . . . . . . . . . . 523
CHAPTER 22
Using ADO.NET 2.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 547
v
674523235.002.png
vi
CONTENTS AT A GLANCE
APPENDIX A
Creating the SQL Tool Application . . . . . . . . . . . . . . . . . . . . . . . . . . . 559
APPENDIX B
XML Primer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 569
INDEX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 583
Zgłoś jeśli naruszono regulamin