Tải bản đầy đủ (.pdf) (7 trang)

a0042 mastering c sharp database programming sybe morebook vn 3517

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (9.47 MB, 7 trang )

Standard print
manual template
© 2004 ... Your company


Title page 1
Use this page to introduce the product
by <AUTHOR>

This is "Title Page 1" - you may use this page to introduce
your product, show title, author, copyright, company logos,
etc.
This page intentionally starts on an odd page, so that it is on
the right half of an open book from the readers point of
view. This is the reason why the previous page was blank
(the previous page is the back side of the cover)


Mastering C# Database Programming
@Team LiB
© 2004 ... Your company
All rights reserved. No parts of this work may be reproduced in any form or by any means - graphic, electronic, or
mechanical, including photocopying, recording, taping, or information storage and retrieval systems - without the
written permission of the publisher.
Products that are referred to in this document may be either trademarks and/or registered trademarks of the
respective owners. The publisher and the author make no claim to these trademarks.
While every precaution has been taken in the preparation of this document, the publisher and the author assume no
responsibility for errors or omissions, or for damages resulting from the use of information contained in this document
or from the use of programs and source code that may accompany it. In no event shall the publisher and the author be
liable for any loss of profit or any other commercial damage caused or alleged to have been caused directly or
indirectly by this document.


Printed: September 2004 in (whereever you are located)

Publisher

Special thanks to:

Technical Editors

All the people who contributed to this document, to mum and dad
and grandpa, to my sisters and brothers and mothers in law, to our
secretary Kathrin, to the graphic artist who created this great
product logo on the cover page (sorry, don't remember your name
at the moment but you did a great work), to the pizza service down
the street (your daily Capricciosas saved our lives), to the copy
shop where this document will be duplicated, and and and...

...enter name...
...enter name...

Last not least, we want to thank EC Software who wrote this great
help tool called HELP & MANUAL which printed this document.

...enter name...
Managing Editor
...enter name...

Cover Designer
...enter name...
Team Coordinator
...enter name...

Production
...enter name...


I

Mastering C# Database Programming @Team LiB

Table of Contents
Foreword

1

Part I Table of Contents

3

Part II BackCover

5

Part III Mastering C# Database Programming

7

Part IV Introduction

9

1 How to Use This

...................................................................................................................................
Book
9
2 Downloading
...................................................................................................................................
the Example Programs
11

Part V Part 1: Introduction to ADO.NET and
Databases

13

1 Chapter 1: Introduction
...................................................................................................................................
to Database Programming with ADO.NET
13
Obtaining the Required
..........................................................................................................................................................
Software
13
Developing Your ..........................................................................................................................................................
First ADO.NET Program
14
Connecting to Access
..........................................................................................................................................................
and Oracle Databases
17
Introducing Visual
..........................................................................................................................................................

Studio .NET
19
Using the .NET Documentation
.......................................................................................................................................................... 23
Using the SQL Server
..........................................................................................................................................................
Documentation
25
Summary
.......................................................................................................................................................... 26

2 Chapter 2: Introduction
...................................................................................................................................
to Databases
26
Introducing Databases
.......................................................................................................................................................... 27
Using SQL Server.......................................................................................................................................................... 28
Exploring the Northwind
..........................................................................................................................................................
Database
34
Building Queries..........................................................................................................................................................
Using Enterprise Manager
43
Creating a Table .......................................................................................................................................................... 45
Summary
.......................................................................................................................................................... 50

3 Chapter 3: Introduction

...................................................................................................................................
to Structured Query Language (SQL)
51
Using SQL
.......................................................................................................................................................... 51
Accessing a Database
..........................................................................................................................................................
Using Visual Studio .NET
70
Summary
.......................................................................................................................................................... 73

4 Chapter 4: Introduction
...................................................................................................................................
to Transact-SQL Programming
73
Fundamentals of ..........................................................................................................................................................
Transact-SQL
74
Using Cursors .......................................................................................................................................................... 77
Using Functions .......................................................................................................................................................... 78
Creating User-Defined
..........................................................................................................................................................
Functions
86
Introducing Stored
..........................................................................................................................................................
Procedures
89
Introducing Triggers

.......................................................................................................................................................... 91
Summary
.......................................................................................................................................................... 94

5 Chapter 5: Overview
...................................................................................................................................
of the ADO.NET Classes
94
The Managed Provider
..........................................................................................................................................................
and Generic Data Set Classes
95
Performing a SQL..........................................................................................................................................................
SELECT Statement and Storing the Rows Locally
98
Summary
.......................................................................................................................................................... 102
© 2004 ... Your company


Contents

II

6 Chapter 6:...................................................................................................................................
Introducing Windows Applications and ADO.NET
102
Developing a Simple
..........................................................................................................................................................
Windows Application

103
Using Windows..........................................................................................................................................................
Controls
109
Using a DataGrid
..........................................................................................................................................................
Control to Access a Database
110
Using the Data Form
..........................................................................................................................................................
Wizard to Create a Windows Form
116
Summary
.......................................................................................................................................................... 124

Part VI Part 2: Fundamental Database Programming
with ADO.NET

126

1 Chapter 7:...................................................................................................................................
Connecting to a Database
126
Understanding the
..........................................................................................................................................................
SqlConnection Class
126
Using a SqlConnection
..........................................................................................................................................................
Object to Connect to a SQL Server Database

128
Creating a Connection
..........................................................................................................................................................
Object Using Visual Studio .NET
132
Summary
.......................................................................................................................................................... 137

2 Chapter 8:...................................................................................................................................
Executing Database Commands
138
The SqlCommand
..........................................................................................................................................................
Class
138
Creating a SqlCommand
..........................................................................................................................................................
Object
140
Executing SELECT
..........................................................................................................................................................
Statements and TableDirect Commands
141
Executing Commands
..........................................................................................................................................................
that Modify Information in the Database
149
Introducing Transactions
.......................................................................................................................................................... 151
Supplying Parameters

..........................................................................................................................................................
to Commands
152
Executing SQL Server
..........................................................................................................................................................
Stored Procedures
156
Creating a Command
..........................................................................................................................................................
Object Using Visual Studio .NET
160
Summary
.......................................................................................................................................................... 161

3 Chapter 9:...................................................................................................................................
Using DataReader Objects to Read Results
162
The SqlDataReader
..........................................................................................................................................................
Class
162
Creating a SqlDataReader
..........................................................................................................................................................
Object
165
Reading Rows from
..........................................................................................................................................................
a SqlDataReader Object
165
Returning Strongly

..........................................................................................................................................................
Typed Column Values
167
Using the Get* Methods
..........................................................................................................................................................
to Read Column Values
168
An Example of Using
..........................................................................................................................................................
the Get* Methods
170
Reading Null Values
.......................................................................................................................................................... 177
Executing Multiple
..........................................................................................................................................................
SQL Statements
177
Using a DataReader
..........................................................................................................................................................
Object in Visual Studio .NET
179
Summary
.......................................................................................................................................................... 181

4 Chapter 10:
...................................................................................................................................
Using Dataset Objects to Store Data
182
The SqlDataAdapter
..........................................................................................................................................................

Class
182
The DataSet Class
.......................................................................................................................................................... 185
Writing and Reading
..........................................................................................................................................................
XML Using a DataSet Object
195
Mapping Tables..........................................................................................................................................................
and Columns
198
Reading a Column
..........................................................................................................................................................
Value Using Strongly Typed DataSet Classes
199
Creating a DataAdapter
..........................................................................................................................................................
Object Using Visual Studio .NET
203
Creating a DataSet
..........................................................................................................................................................
Object Using Visual Studio .NET
207
Summary
.......................................................................................................................................................... 208

5 Chapter 11:
...................................................................................................................................
Using DataSet Objects to Modify Data
208

The DataTable Class
.......................................................................................................................................................... 209
The DataRow Class
.......................................................................................................................................................... 211
The DataColumn..........................................................................................................................................................
Class
212
Adding Restrictions
..........................................................................................................................................................
to DataTable and DataColumn Objects
213
Finding, Filtering,
..........................................................................................................................................................
and Sorting Rows in a DataTable
221
Modifying Rows..........................................................................................................................................................
in a DataTable
223
© 2004 ... Your company


376

Mastering C# Database Programming @Team LiB

Endnotes 2... (after index)

© 2004 ... Your company



Back Cover



×