(Ebook) Practical Database Programming with Visual Basic.NET by Ying Bai ISBN 9780521712354, 9780521885188, 0521712351, 0521885183 download pdf
(Ebook) Practical Database Programming with Visual Basic.NET by Ying Bai ISBN 9780521712354, 9780521885188, 0521712351, 0521885183 download pdf
ebooknice.com
ebooknice.com
ebooknice.com
ebooknice.com
(Ebook) Biota Grow 2C gather 2C cook by Loucas, Jason;
Viles, James ISBN 9781459699816, 9781743365571,
9781925268492, 1459699815, 1743365578, 1925268497
https://ebooknice.com/product/biota-grow-2c-gather-2c-cook-6661374
ebooknice.com
https://ebooknice.com/product/practical-database-programming-with-
java-2501314
ebooknice.com
ebooknice.com
ebooknice.com
https://ebooknice.com/product/sat-ii-success-
math-1c-and-2c-2002-peterson-s-sat-ii-success-1722018
ebooknice.com
Practical Database Programming with Visual Basic NET
1st Edition Ying Bai Digital Instant Download
Author(s): Ying Bai
ISBN(s): 9780521885188, 0521885183
Edition: 1
File Details: PDF, 45.71 MB
Year: 2008
Language: english
This page intentionally left blank
Practical Database Programming with Visual Basic.NET
Ying Bai
Johnson C. Smith University
www.cambridge.org
Information on this title: www.cambridge.org/9780521885188
© Ying Bai 2009
1. Introduction 1
1.1 Outstanding Features of This Book 2
1.2 Whom This Book Is For 2
1.3 What This Book Covers 3
1.4 How This Book Is Organized and How to Use This Book 5
1.5 How to Use the Source Code and Sample Databases 6
1.6 Instructor and Customer Support 7
1.7 Homework Solutions 8
2. Introduction to Databases 10
2.1 What Are Databases and Database Programs? 11
2.1.1 File Processing System 11
2.1.2 Integrated Databases 12
2.2 Developing a Database 13
2.3 Sample Database 14
2.3.1 Relational Data Model 14
2.3.2 Entity-Relationship (ER) Model 17
2.4 Identifying Keys 18
2.4.1 Primary Key and Entity Integrity 18
2.4.2 Candidate Key 19
2.4.3 Foreign Keys and Referential Integrity 19
2.5 Define Relationships 19
2.5.1 Connectivity 19
2.6 ER Notation 23
2.7 Data Normalization 23
2.7.1 First Normal Form 24
2.7.2 Second Normal Form 24
2.7.3 Third Normal Form 25
vii
viii Contents
3. Introduction to ADO.NET 87
3.1 ADO and ADO.NET 87
3.2 Overview of ADO.NET 88
3.3 The Architecture of ADO.NET 89
3.4 The Components of ADO.NET 91
3.4.1 The Data Provider 91
3.4.1.1 The ODBC Data Provider 92
3.4.1.2 The OLE DB Data Provider 93
3.4.1.3 The SQL Server Data Provider 93
3.4.1.4 The Oracle Data Provider 93
3.4.2 The Connection Class 94
3.4.2.1 The Open() Method of the Connection Class 96
3.4.2.2 The Close() Method of the Connection Class 97
3.4.2.3 The Dispose() Method of the Connection
Class 97
3.4.3 The Command and Parameter Classes 98
3.4.3.1 The Properties of the Command Class 99
3.4.3.2 The Constructors and Properties of the
Parameter Class 99
3.4.3.3 Parameter Mapping 100
3.4.3.4 The Methods of the ParameterCollection
Class 102
3.4.3.5 The Constructor of the Command Class 104
3.4.3.6 The Methods of the Command Class 105
3.4.3.6.1 The ExecuteReader Method 105
3.4.3.6.2 The ExecuteScalar Method 106
3.4.3.6.3 The ExecuteNonQuery Method 106
3.4.4 The DataAdapter Class 107
3.4.4.1 The Constructor of the DataAdapter Class 108
3.4.4.2 The Properties of the DataAdapter Class 108
3.4.4.3 The Methods of the DataAdapter Class 108
3.4.4.4 The Events of the DataAdapter Class 109
3.4.5 The DataReader Class 110
x Contents
Index 781
Preface
xxvii
xxviii Preface
programming with Visual Basic 2005, along with authentic examples and detailed
explanations. More important, a new writing style implemented in this book, com-
bined with real examples, provides readers with a clear picture of how to handle
database programming issues in the Visual Basic.NET 2005 environment.
The outstanding features of this book include, but are not limited to, the follow-
ing:
1. A unique writing style is adopted to try to attract students’ or beginning pro-
grammers’ interest in learning and developing practical database programs,
and to avoid the headache caused by huge blocks of code, as is common in
traditional database programming books.
2. A real, completed sample database, CSE DEPT, with three versions
(Microsoft Access, SQL Server 2005, and Oracle Database 10g XE), is pro-
vided and used for the entire book. Step-by-step, detailed illustrations and
descriptions about how to design and build a practical relational database are
provided.
3. Both fundamental and advanced database programming techniques are cov-
ered for the convenience of both beginning students and experienced pro-
grammers.
4. Three types of popular databases are covered and discussed in detail with
practical sample examples: Microsoft Access, SQL Server 2005, and Oracle
Database 10g XE.
5. Various actual data providers are discussed and implemented in the sample
projects, such as the SQL Server and Oracle data providers. Instead of using
OLE DB to access the SQL Server or Oracle databases, real SQL Server
and Oracle data providers are utilized to connect to Visual Basic.NET 2005
directly to perform data operations.
6. It is a good textbook for college students and a good reference book for pro-
grammers, software engineers, and academic researchers.
I sincerely hope that this book will help readers or users develop and build pro-
fessional and practical database applications.
Acknowledgments
The first and most special thanks go to my wife, Yan Wang. I could not have finished
this book without her sincere encouragement and support.
I would also like to thank Dr. Satish Bhalla, who is the chapter contributor for
this book. He is a specialist in database programming and management, especially
in SQL Server, Oracle, and DB2. Dr. Bhalla spent a lot of time preparing materials
for Chapter 2, and he deserves thanks for this.
Many thanks to my editor, Heather Bergman, for helping to make this book a
reality. You would not have found this book in the market without her deep per-
spective and hard work. Thanks are also extended to the editing team of this book.
Without their contributions, it would have been impossible for this book to get pub-
lished.
Thanks should also be extended to the following book reviewers for their invalu-
able opinions on this book:
Dr. Jifeng Xu, Research Scientist, The Boeing Company
Dr. Xiaohong Yuan, Associate Professor, Department of Computer Science,
North Carolina A&T State University
Dr. Daoxi Xiu, Application Analyst Programmer, North Carolina Administra-
tive Office of the Courts
Dr. Dali Wang, Assistant Professor, Department of Physics and Computer Sci-
ence, Christopher Newport University
Last but not least, I thank all the people who supported me in finishing this book.
xxix
Practical Database Programming with Visual Basic.NET
1
Introduction
For years, during my teaching of database programming and Visual Basic.NET pro-
gramming at the college level, I found it so difficult to find a good textbook for
these topics that I had to combine a few different professional books together as
references to teach my course. Most of those books are specially designed for pro-
grammers or software engineers, cover a lot of programming strategies, and include
huge blocks of code, which cause terrible headaches for college students or begin-
ning programmers who are new to Visual Basic.NET and database programming. I
had to prepare my class presentations and figure out all the homework and exercises
for my students. I dreamed that one day I would find a good textbook that would be
suitable for college students or beginning programmers to help them learn and mas-
ter database programming with Visual Basic.NET easily and conveniently. Finally I
decided that I needed to do something about this dream myself after a long period
of waiting.
Another reason I had the idea for this book is the job market. As you know,
most industrial and commercial companies in the United States are database appli-
cation businesses, such as manufacturers, banks, hospitals, and retail stores. A
majority of them need professional people to develop and build database-related
applications, but not database management and design systems. To enable our stu-
dents to become good candidates for those companies, we need a book like this
one.
Unlike most of the database programming books in the current market, which
discuss and present database programming techniques with huge blocks of program-
ming code from the first page to the last page, this book uses a new writing style to
show readers, especially college students, how to develop professional and practi-
cal database programs in Visual Basic.NET by using Visual Basic.NET 2005 Design
Tools and Wizards related to ADO.NET 2.0 and how to apply code that is auto-
generated by using Wizards. With this new style, the headache caused by those huge
blocks of programming code is eliminated. Instead, a simple and easy way to create
database programs using the Design Tools can be developed to attract students’
1
2 Introduction
interest and enable students to build professional and practical databases in more
efficient and interesting ways.
There are so many different database programming books available in the mar-
ket, but one can rarely find a book like this one, which implements a new writing
style to hold students’ interest. To meet the needs of experienced or advanced stu-
dents and software engineers, the book contains two programming methods: the
fundamental database programming method using Visual Basic.NET 2005 Design
Tools and Wizards and the advanced database programming method using the
runtime object method. In the second method, all database-related objects are
created and applied while the project is running by utilizing a few blocks of
code.
This chapter is divided into two parts. Methods 1 and 2 are related to Visual
Basic.NET design tools and wizards and therefore are covered in Part I. The
third method is related to runtime objects and therefore is covered in Part II.
4 Introduction
Nine real projects are used to illustrate how to perform data insertion in three
different databases: Access, SQL Server 2005, and Oracle Database 10g XE.
Some professional and practical data validation methods are also discussed in
this chapter to confirm the data insertion.
Chapter 6 provides discussions and analyses of three popular data updating and
deleting methods:
This chapter is also divided into two parts. Methods 1 and 2 are related to Visual
Basic.NET design tools and wizards and therefore are covered in Part I. The
third method is related to runtime objects and is covered in Part II. Seven real
projects are used to illustrate how to perform data updating and deleting in three
different databases: Access, SQL Server 2005, and Oracle Database 10g XE.
Some professional and practical data validation methods are also discussed in
this chapter to confirm the data updating and deleting actions. The key points to
remember when updating and deleting data in a relational database, such as the
order in which to execute data updating and deleting in parent and child tables,
are also discussed and analyzed.
Chapter 7 provides introductions to and discussions about the development and
implementation of ASP.NET Web applications in the Visual Basic.NET 2005
environment. At the beginning of Chapter 7, detailed and complete descrip-
tions ASP.NET and Microsoft .NET Framework are provided. This part is
especially useful and important to students or programmers who do not have
any knowledge of or background in Web application development and imple-
mentation. Following the introduction section, a detailed discussion of how
to install and configure the environment to develop ASP.NET Web appli-
cations is provided. Some essential tools, such as the Web server, Internet
Information Services (IISs), and FrontPage Server Extension 2000 or 2002,
and the installation process for these tools are introduced and discussed in
detail. Starting with Section 7.3, the detailed development and building pro-
cesses of ASP.NET Web applications to access databases are discussed with six
real Web application projects. Two popular databases, SQL Server and Ora-
cle, are utilized as the target databases for these development and building
processes.
Chapter 8 provides introductions to and discussions about the development
and implementation of ASP.NET Web services in the Visual Basic.NET
2005 environment. A detailed discussion and analysis of the structure and
1.4 How This Book Is Organized and How to Use This Book 5
Each Web service contains different Web methods that can be used to access
different databases and perform the desired data actions, such as Select, Insert,
Update, and Delete, via the Internet. To consume those Web services, different
Web service client projects are also developed in this chapter. Both Windows-
based and Web-based Web service client projects are discussed and built for
each kind of Web service listed above. In all, eighteen projects, including the
Web service projects and the associated Web service client projects, are devel-
oped in this chapter. All projects have been debugged and tested and can be run
in Windows-compatible operating systems such as Windows 95, 98, 2000, XP,
and Vista.
1.4 HOW THIS BOOK IS ORGANIZED AND HOW TO USE THIS BOOK
This book is designed for both college students who are new to database program-
ming with Visual Basic.NET and professional database programmers who have
experience with this topic.
Chapters 2 and 3 provide the fundamentals of database structures and compo-
nents of ADO.NET. Chapters 4, 5, and 6 are each divided into two parts, a fun-
damental part and an advanced part. The data-driven applications developed with
design tools and wizards provided by Visual Basic.NET in the fundamental part
have less coding, and therefore are more suitable for students or programmers who
are new to database programming with Visual Basic.NET. Part II contains the run-
time object method and covers the development of code to perform different data
actions on the database. This method is more flexible and convenient for experi-
enced programmers because a lot of coding is required.
Chapters 7 and 8 give a full discussion and analysis the development and
implementation of ASP.NET Web applications and Web services. These technolo-
gies are necessary for students and programmers who want to develop and build
Web applications and Web services to access and manipulate data through the
Internet.
This book is organized so that it can be used at two levels, which are shown in
Figure 1.1.
It is highly recommended that undergraduate college students and beginning
programmers learn and understand the contents of Chapters 2 and 3 and Part I of
Chapters 4, 5, and 6 since those provide fundamental knowledge and techniques of
database programming with Visual Basic.NET 2005. Chapters 7 and 8 are optional
for instructors and depend on the time and schedule.
Step by step, a detailed description is given to illustrate how to design and set
up relationships between parent and child tables using the primary key and foreign
6 Introduction
keys for Access, SQL Server 2005, and Oracle Database 10g XE databases. In Part
I of Chapters 4–6, Visual Basic.NET design tools and wizards are discussed and
analyzed in detail to show readers how to use them to easily and conveniently design
and build professional database programs with Visual Basic.NET.
For experienced college students or software programmers who already have
some knowledge of database programming, it is recommended to learn and under-
stand the contents of Part II of Chapters 4–6 as well as Chapters 7 and 8 since
the runtime data object method and some sophisticated database programming
techniques, such as joined-table query, nested stored procedures, and Oracle
Package, are discussed and illustrated with real examples. Also, ASP.NET Web
applications and ASP.NET Web services are discussed and analyzed with twenty-
four real database program examples for SQL Server 2005 and Oracle Database
10g XE.
1.D. The copyright laws of the place where you are located also
govern what you can do with this work. Copyright laws in most
countries are in a constant state of change. If you are outside the
United States, check the laws of your country in addition to the terms
of this agreement before downloading, copying, displaying,
performing, distributing or creating derivative works based on this
work or any other Project Gutenberg™ work. The Foundation makes
no representations concerning the copyright status of any work in
any country other than the United States.
• You pay a royalty fee of 20% of the gross profits you derive from
the use of Project Gutenberg™ works calculated using the
method you already use to calculate your applicable taxes. The
fee is owed to the owner of the Project Gutenberg™ trademark,
but he has agreed to donate royalties under this paragraph to
the Project Gutenberg Literary Archive Foundation. Royalty
payments must be paid within 60 days following each date on
which you prepare (or are legally required to prepare) your
periodic tax returns. Royalty payments should be clearly marked
as such and sent to the Project Gutenberg Literary Archive
Foundation at the address specified in Section 4, “Information
about donations to the Project Gutenberg Literary Archive
Foundation.”
• You comply with all other terms of this agreement for free
distribution of Project Gutenberg™ works.
1.F.
1.F.4. Except for the limited right of replacement or refund set forth in
paragraph 1.F.3, this work is provided to you ‘AS-IS’, WITH NO
OTHER WARRANTIES OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO WARRANTIES OF
MERCHANTABILITY OR FITNESS FOR ANY PURPOSE.
Please check the Project Gutenberg web pages for current donation
methods and addresses. Donations are accepted in a number of
other ways including checks, online payments and credit card
donations. To donate, please visit: www.gutenberg.org/donate.
Most people start at our website which has the main PG search
facility: www.gutenberg.org.
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
ebooknice.com