Wrox - Beginning Visual Basic 2005 Databases (2006).pdf

(3354 KB) Pobierz
Beginning Visual Basic 2005 Databases
TEAM LinG
29900722.005.png
Beginning Visual Basic®2005 Databases
Published by
Wiley Publishing, Inc.
10475 Crosspoint Boulevard
Indianapolis, IN 46256
www.wiley.com
Copyright © 2006 by Wiley Publishing, Inc., Indianapolis, Indiana
Published simultaneously in Canada
ISBN: 0-7645-8894-X
Manufactured in the United States of America
10 9 8 7 6 5 4 3 2 1
1B/QR/RR/QV/IN
Library of Congress Cataloging-in-Publication Data:
Willis, Thearon.
Beginning Visual Basic 2005 databases / Thearon Willis.
p. cm.
Includes bibliographical references and index.
ISBN-13: 978-0-7645-8894-5 (paper/website)
ISBN-10: 0-7645-8894-X (paper/website)
1. Web databases. 2. Client/server computing. 3. Microsoft Visual BASIC. I. Title.
QA76.9.W43W42 2005
005.2’768--dc22
2005013967
No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any
means, electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections
107 or 108 of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or
authorization through payment of the appropriate per-copy fee to the Copyright Clearance Center, 222 Rosewood
Drive, Danvers, MA 01923, (978) 750-8400, fax (978) 646-8600. Requests to the Publisher for permission should be
addressed to the Legal Department, Wiley Publishing, Inc., 10475 Crosspoint Blvd., Indianapolis, IN 46256, (317)
572-3447, fax (317) 572-4355, or online at http://www.wiley.com/go/permissions.
LIMIT OF LIABILITY/DISCLAIMER OF WARRANTY: THE PUBLISHER AND THE AUTHOR MAKE NO REP-
RESENTATIONS OR WARRANTIES WITH RESPECT TO THE ACCURACY OR COMPLETENESS OF THE CON-
TENTS OF THIS WORK AND SPECIFICALLY DISCLAIM ALL WARRANTIES, INCLUDING WITHOUT
LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE. NO WARRANTY MAY BE CRE-
ATED OR EXTENDED BY SALES OR PROMOTIONAL MATERIALS. THE ADVICE AND STRATEGIES CON-
TAINED HEREIN MAY NOT BE SUITABLE FOR EVERY SITUATION. THIS WORK IS SOLD WITH THE
UNDERSTANDING THAT THE PUBLISHER IS NOT ENGAGED IN RENDERING LEGAL, ACCOUNTING, OR
OTHER PROFESSIONAL SERVICES. IF PROFESSIONAL ASSISTANCE IS REQUIRED, THE SERVICES OF A
COMPETENT PROFESSIONAL PERSON SHOULD BE SOUGHT. NEITHER THE PUBLISHER NOR THE
AUTHOR SHALL BE LIABLE FOR DAMAGES ARISING HEREFROM. THE FACT THAT AN ORGANIZATION
OR WEBSITE IS REFERRED TO IN THIS WORK AS A CITATION AND/OR A POTENTIAL SOURCE OF FUR-
THER INFORMATION DOES NOT MEAN THAT THE AUTHOR OR THE PUBLISHER ENDORSES THE INFOR-
MATION THE ORGANIZATION OR WEBSITE MAY PROVIDE OR RECOMMENDATIONS IT MAY MAKE.
FURTHER, READERS SHOULD BE AWARE THAT INTERNET WEBSITES LISTED IN THIS WORK MAY HAVE
CHANGED OR DISAPPEARED BETWEEN WHEN THIS WORK WAS WRITTEN AND WHEN IT IS READ.
For general information on our other products and services please contact our Customer Care Department within
the United States at (800) 762-2974, outside the United States at (317) 572-3993 or fax (317) 572-4002.
Trademarks: Wiley, the Wiley logo, Wrox, the Wrox logo, Programmer to Programmer, and related trade dress are
trademarks or registered trademarks of John Wiley & Sons, Inc. and/or its affiliates, in the United States and other
countries, and may not be used without written permission. Visual Basic is a registered trademark of Microsoft
Corporation in the United States and/or other countries. All other trademarks are the property of their respective
owners. Wiley Publishing, Inc., is not associated with any product or vendor mentioned in this book.
Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may not be
available in electronic books.
29900722.006.png
Contents
Acknowledgments
xvii
Introduction
xix
Chapter 1: Databases
1
Access Databases
2
Database file
2
Tables
2
Queries
3
SQL Server Databases
3
Data files
4
Log files
7
Oracle Databases
7
Data files
8
Redo log files
10
Control files
10
Temp files
10
Password files
10
Relational Database Design
10
Normalization
12
Building the Case Study Databases
15
Access schema
15
SQL Server schema
20
Oracle schema
25
Summary
30
Chapter 2: An Introduction to ADO.NET
31
ADO.NET Overview
31
ADO.NET architecture
32
ADO.NET components
33
Connection Class
37
Common constructors
37
Opening a connection
39
Closing a connection
39
29900722.007.png
Contents
Command Class
40
DataAdapter Class
41
DataReader Class
43
Summary
44
Exercises
45
Exercise 1
45
Exercise 2
45
Chapter 3: Visual Studio 2005 Data Wizards
47
Data Access Components
47
DataSet
48
DataGridView
48
BindingSource
49
BindingNavigator
49
TableAdapter
49
Data Binding
49
Summary
56
Exercises
57
Exercise 1
57
Exercise 2
57
Chapter 4: Basic SQL
59
INSERT Statement
59
SELECT Statement
65
UPDATE Statement
67
DELETE Statement
69
Summary
71
Exercises
72
Exercise 1
72
Exercise 2
72
Chapter 5: SQL and Queries for Access
73
Dynamic Connections
73
Building a connection string
74
Opening, closing, and checking connection state
75
In-Line SQL
81
Summary
104
Exercises
105
Exercise 1
105
Exercise 2
106
xii
29900722.008.png 29900722.001.png
 
29900722.002.png
Contents
Chapter 6: Selecting Data in Access
107
Building the Time Tracker Application
107
Implementing SQL Queries
109
Summary
121
Exercises
121
Exercise 1
121
Exercise 2
121
Chapter 7: Inserting, Updating, and Deleting Data in Access
123
OleDbCommand Object
123
Group Queries
136
Summary
154
Exercises
155
Exercise 1
155
Exercise 2
156
Chapter 8: Migrating Data from Access
157
Dynamic Connections
157
SQL Statement Parameters
167
Summary
177
Exercises
178
Exercise 1
178
Exercise 2
178
Chapter 9: Stored Procedures and Views for SQL Server and Oracle
179
Stored Procedures
180
Oracle packages
182
Views
205
Creating a view
207
Summary
232
Exercises
233
Exercise 1
233
Exercise 2
233
xiii
29900722.003.png
 
29900722.004.png
Zgłoś jeśli naruszono regulamin