(PDF Download) Oracle Database Programming With Visual Basic - NET: Concepts, Designs and Implementations Ying Bai Fulll Chapter
(PDF Download) Oracle Database Programming With Visual Basic - NET: Concepts, Designs and Implementations Ying Bai Fulll Chapter
com
https://ebookmass.com/product/oracle-
database-programming-with-visual-basic-net-
concepts-designs-and-implementations-ying-
bai/
ebookmass.com
More products digital (pdf, epub, mobi) instant
download maybe you interests ...
https://ebookmass.com/product/clearly-visual-basic-programming-
with-microsoft-visual-basic-2010-second-edition-diane-zak/
https://ebookmass.com/product/programming-with-microsoft-visual-
basic-2017-8th-edition-diane-zak/
https://ebookmass.com/product/blockchain-essentials-core-
concepts-and-implementations-1st-edition-ramchandra-sharad-
mangrulkar/
https://ebookmass.com/product/oracle-autonomous-database-for-
dummies-3rd-special-edition-lawrence-miller/
Simple and Efficient Programming with C#: Skills to
Build Applications with Visual Studio and .NET 2nd
Edition Vaskaran Sarcar
https://ebookmass.com/product/simple-and-efficient-programming-
with-c-skills-to-build-applications-with-visual-studio-and-
net-2nd-edition-vaskaran-sarcar/
https://ebookmass.com/product/simple-and-efficient-programming-
with-c-skills-to-build-applications-with-visual-studio-and-
net-2nd-edition-vaskaran-sarcar-2/
https://ebookmass.com/product/database-system-concepts-6th-
edition-ebook-pdf/
https://ebookmass.com/product/database-system-concepts-7th-
edition-avi-silberschatz/
https://ebookmass.com/product/database-system-concepts-7th-
edition-abraham-silberschatz/
Oracle Database Programming with Visual Basic.NET
IEEE Press
445 Hoes Lane
Piscataway, NJ 08854
Ying Bai
Department of Computer Science and Engineering
Johnson C. Smith University
Charlotte, North Carolina
Copyright © 2021 by The Institute of Electrical and Electronics Engineers, Inc. All rights reserved.
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
Section 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, Inc., 222 Rosewood Drive, Danvers, MA 01923, (978) 750-8400, fax (978) 750-4470, or on the web at
www.copyright.com. Requests to the Publisher for permission should be addressed to the Permissions Department,
John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030, (201) 748-6011, fax (201) 748-6008, or online at
http://www.wiley.com/go/permission.
Limit of Liability/Disclaimer of Warranty: While the publisher and author have used their best efforts in preparing
this book, they make no representations or warranties with respect to the accuracy or completeness of the contents
of this book and specifically disclaim any implied warranties of merchantability or fitness for a particular purpose.
No warranty may be created or extended by sales representatives or written sales materials. The advice and
strategies contained herein may not be suitable for your situation. You should consult with a professional where
appropriate. Neither the publisher nor author shall be liable for any loss of profit or any other commercial damages,
including but not limited to special, incidental, consequential, or other damages.
For general information on our other products and services or for technical support, 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.
Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may not be
available in electronic formats. For more information about Wiley products, visit our web site at www.wiley.com.
ISBN: 9781119734390
10 9 8 7 6 5 4 3 2 1
This book is dedicated to my wife, Yan Wang, and my daughter, Susan (Xue) Bai.
vii
Contents
1 Introduction 1
1.1 Outstanding Features About This Book 2
1.2 Who This Book Is For 2
1.3 What This Book Covered 2
1.4 How This Book Is Organized and How to Use This Book 4
1.5 How to Use Appendices and Related Materials 6
1.6 How to Use Source Codes and Sample Database 8
1.7 Instructors and Customer Supports 9
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 11
2.2 Develop a Database 12
2.3 Sample Database 13
2.3.1 Relational Data Model 13
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 22
2.7 Data Normalization 22
2.7.1 First Normal Form (1NF) 23
2.7.2 Second Normal Form (2NF) 23
2.7.3 Third Normal Form (3NF) 24
2.8 Database Components in Some Popular Databases 25
2.8.1 Microsoft Access Databases 27
viii Contents
3 Introduction to ADO.NET 77
3.1 The ADO and ADO.NET 77
3.2 Overview of the ADO.NET 79
3.3 The Architecture of the ADO.NET 80
3.4 The Components of ADO.NET 81
3.4.1 The Data Provider 81
3.4.2 The Connection Class 84
3.4.3 The Command and the Parameter Classes 87
3.4.4 The DataAdapter Class 95
3.4.5 The DataReader Class 98
3.4.6 The DataSet Component 101
3.4.7 The DataTable Component 105
3.4.8 ADO.NET Entity Framework 111
3.5 Chapter Summary 118
7.2.7 Develop Codes to Delete Data Using the TableAdapter DBDirect Method 367
7.2.8 Develop Codes to Delete Data Using the TableAdapter.Update Method 368
7.2.9 Validate the Data After the Data Updating and Deleting 369
Part II: Data Updating and Deleting with Runtime Objects 372
7.3 The Run Time Objects Method 373
7.4 Update and Delete Data for Oracle Database Using the Run Time Objects 374
7.4.1 Update Data Against the Faculty Table in the Oracle Database 375
7.4.2 Delete Data From the Faculty Table in the Oracle Database 377
7.5 Update and Delete Data against Oracle Database Using Stored Procedures 381
7.5.1 Modify the Existing Project to Create Our New Project 382
7.5.2 Create the Codes to Update and Delete Data from the Course Table 382
7.5.3 Update and Delete Data Using the LINQ to DataSet Query 392
7.6 Chapter Summary 395
Index 649
xiv
Dr. YING BAI is a Professor in the Department of Computer Science and Engineering at Johnson
C. Smith University. His special interests include: artificial intelligences, soft computing, mixed-
language programming, fuzzy logic and deep learning, robotic controls, robots calibrations, and
database programming.
His industry experience includes positions as software engineer and senior software engineer at
companies such as Motorola MMS, Schlumberger ATE Technology, Immix TeleCom, and Lam
Research.
Since 2003, Dr. Bai has published sixteen (16) books with publishers such as Prentice Hall, CRC
Press LLC, Springer, Cambridge University Press, and Wiley IEEE Press. The Russian translation
of his first book titled Applications Interface Programming Using Multiple Languages was published
by Prentice Hall in 2005. The Chinese translation of his eighth book titled Practical Database
Programming with Visual C#.NET was published by Tsinghua University Press in China in 2011.
Most books are about software programming, serial port programming, fuzzy logic controls in
industrial applications, microcontroller controls and programming as well as classical and modern
controls on microcontrollers.
During recent years, Dr. Bai has also published more than sixty (60) academic research papers in
IEEE Trans. Journals and International conferences.
xv
Preface
Databases have become an integral part of our modern-day life. We are an information-driven
society. Database technology has a direct impact on our daily lives. Decisions are routinely made
by organizations based on the information collected and stored in the databases. A record com-
pany may decide to market certain albums in selected regions based on the music preference of
teenagers. Grocery stores display more popular items at the eye level and reorders are based on the
inventories taken at regular intervals. Other examples include patients’ records in hospitals, cus-
tomers’ account information in banks, book orders by the libraries, club memberships, auto part
orders, and winter cloth stock by department stores, and many others.
In addition to database management systems, in order to effectively apply and implement data-
bases in real industrial or commercial systems, a good Graphic User Interface (GUI) is needed to
allow users to access and manipulate their records or data in databases. Visual Basic.NET is an
ideal candidate to be selected to provide this GUI functionality. Unlike other programming lan-
guages, Visual Basic.NET is a kind of language that has advantages such as easy-to-learn and easy-
to-be-understood with little learning curves. In the beginning of Visual Studio.NET 2005, Microsoft
integrated a few programming languages such as Visual C++, Visual Basic, C#, and Visual J# into
a dynamic model called .NET Framework that makes Internet and Web programming easy and
simple, and any language integrated in this model can be used to develop professional and efficient
Web applications that can be used to communicate with others via Internet. ADO.NET and ASP.
NET are two important submodels of .NET Framework. The former provides all components,
including the Data Providers, DataSet, and DataTable, to access and manipulate data against dif-
ferent databases. The latter provides support to develop Web applications and Web services in ASP.
NET environment to allow users to exchange information between clients and servers easily and
conveniently.
This book is mainly designed for college students and software programmers who want to
develop practical and commercial database programming with Visual Basic.NET and relational
database such as Oracle XE 18c. The book provides a detailed description about the practical con-
siderations and applications in database programming with Visual Basic.NET 2019 with authentic
examples and detailed explanations. More important, a new writing style is developed and imple-
mented in this book, combined with real examples, to provide readers with a clear picture as how
to handle the database programming issues in Visual Basic.NET 2019 environment.
The outstanding features of this book include, but no limited to:
1) A novel writing style is adopted to try to attract students’ or beginning programmers’ interest in
learning and developing practical database programs and to avoid the headache caused by
using huge blocks of codes in the traditional database programming books.
xvi Preface
2) Updated database programming tools and components are covered in the book, such as .NET
Framework 4.7, LINQ, ADO.NET 4.6, and ASP.NET 4.6, to enable readers to easily and quickly
learn and master advanced techniques in database programming and develop professional and
practical database applications.
3) A real completed sample Oracle XE 18c database CSE_DEPT is provided and used for the entire
book. Step by step, a detailed illustration and description about how to design and build a prac-
tical relational database are provided.
4) Covered both fundamental and advanced database-programming techniques to the conveni-
ence of both beginning students and experienced programmers.
5) All projects can be run in Microsoft Visual Studio.NET 2019 with Oracle XE 18c database.
6) Good textbook for college students, good reference book for programmers, software engineers,
and academic researchers.
I sincerely hope that this book can provide useful and practical help and guide to all readers or
users who adopted this book, and I will be more than happy to know that you guys can develop and
build professional and practical database applications with the help of this book.
Ying Bai
xvii
Acknowledgments
First, a special thanks to my wife, Yan Wang, for I could not have finished this book without her
sincere encouragement and support.
Special thanks also to Dr. Satish Bhalla, a specialist in database programming and management,
especially in SQL Server, Oracle, and DB2, who spent a lot of time preparing materials for Chapter 2.
Many thanks to the Senior Editor, Mary Hatcher, who made this book available to the public,
without whose perseverance and hard work this book would not be available in the market. Thanks
should also go to the entire editorial team for all their contributions which made it possible to
publish this book.
Thanks are extended to the following book reviewers for their valuable suggestions and inputs:
●● Dr. Jiang (Linda) Xie, Professor, Department of Electrical and Computer Engineering, University
of North Carolina at Charlotte.
●● Dr. Dali Wang, Professor, Department of Physics and Computer Science, Christopher Newport
University.
●● Dr. Daoxi Xiu, Application Analyst Programmer, North Carolina Administrative Office of the
Courts.
Finally, but not the least, I would like to express my gratitude to all the people who supported me
in completing this book.
xviii
www.wiley.com/go/bai-VB-Oracle
Introduction
For many years during my teaching Visual Basic.NET programming and database-related
programming courses in my college, I found that it is not easy to find a good textbook for this topic
and I had to combine a few different professional books together as references to teach these
courses. Most of those books are specially designed for programmers or software engineers, which
cover a lot of programming strategies and huge blocks of codes, which is a terrible headache to the
college students or beginning programmers who are new to the Visual Basic.NET and database
programming. I have to prepare my class presentations and figure out all home works and exer-
cises for my students. I dream that one day I could find a good textbook that is suitable for the
college students or beginning programmers and could be used to help them to learn and master the
database programming with Visual Basic.NET easily and conveniently. Finally, I decided that I
need to do something for this dream myself after a long time waiting.
Another reason for me to have this idea is the job market. As you know, most industrial and com-
mercial companies in US belong to database application businesses such as manufactures, banks,
hospitals, and retails. Majority of them need professional people to develop and build database-
related applications but not database management and design systems. To enable our students to
become good candidates for those companies, we need to create a book like this one.
Unlike most of database programming books in the current market, which discuss and present
the database programming techniques with huge blocks of programming codes from the first page
to the last page, this book tries to use a new writing style to show readers, especially to the college
students, how to develop professional and practical database programs with Visual Basic.NET by
using Visual Studio.NET Design Tools and Wizards related to ADO.NET and to apply codes that
are auto-generated by various Wizards. By using this new style, the over headache caused by using
huge blocks of programming codes can be removed; instead, a simple and easy way to create
database programs using the Design Tools can be taken to attract students’ learning interest and
furthermore to enable students to build professional and practical database programming in more
efficient and interesting ways.
There are so many different database-programming books available on the market, but rarely
can you find a book like this one, which implemented a novel writing style to attract the students’
learning interests in this topic. To meet the needs of some experienced or advanced students or
software engineers, the book contains two programming methods: the interesting and easy-to-
learn fundamental database programming method – Visual Studio.NET Design Tools and
Oracle Database Programming with Visual Basic.NET: Concepts, Designs, and Implementations, First Edition. Ying Bai.
© 2021 The Institute of Electrical and Electronics Engineers, Inc. Published 2021 by John Wiley & Sons, Inc.
Companion website: www.wiley.com/go/bai-VB-Oracle
2 1 Introduction
Wizards – and the advanced database programming method – runtime object method. In the
second method, all database-related objects are created and applied during or when your project is
running by utilizing quite a few blocks of codes.
1) All programming projects can be run in Microsoft Visual Studio.NET 2019 with Oracle XE 18c
databases.
2) A novel writing style is adopted to try to attract students’ or beginning programmers’ interests
in learning and developing practical database programs and to avoid the headache caused by
using huge blocks of codes in the traditional database programming books.
3) Updated database programming tools and components are covered in the book, such as .NET
Framework 4.7, LINQ, ADO.NET 4.6, and ASP.NET 4.7, to enable readers to easily and quickly
learn and master advanced techniques in database programming and develop professional and
practical database applications.
4) A real completed sample database CSE_DEPT with Oracle XE 18c database engine is provided
and used for the entire book. Step by step, a detailed illustration and description about how to
design and build a practical relational database are provided.
5) Covered both fundamental and advanced database programming techniques to convenience
both beginning students and experienced programmers.
6) Provides homework and exercises for students and teaching materials for instructors, and these
enable students to understand what they learned better by doing something themselves and
allow instructors to organize and prepare their courses easily and rapidly.
7) Good textbook for college students, good reference book for programmers, software engineers,
and academic researchers.
This book is designed for college students and software programmers who want to develop practi-
cal and commercial database programming with Visual Basic.NET and relational databases such
as Oracle XE 18c. Fundamental knowledge and understanding on Visual Basic.NET and Visual
Studio.NET IDE is assumed.
Nine (9) chapters are included in this book. The contents of each chapter can be summarized as
below.
●● Chapter 1 provides an introduction and summarization to the whole book.
●● Chapter 2 provides detailed discussions and analyses of the structure and components about
relational databases. Some key technologies in developing and designing database are also given
and discussed in this part. The procedure and components used to develop a practical relational
database with Oracle XE 18c are analyzed in detailed with some real data tables in our sample
database CSE_DEPT.
1.3 What This Book Covere 3
●● Chapter 3 provides an introduction to the ADO.NET, which includes the architectures, organizations,
and components of the ADO.NET. Detailed discussions and descriptions are provided in this chap-
ter to give readers both fundamental and practical ideas and pictures in how to use components in
ADO.NET to develop professional data-driven applications. Two ADO.NET architectures are dis-
cussed to enable users to follow the directions to design and build their preferred projects based on
the different organizations of the ADO.NET. Four popular data providers, such as OleDb, ODBC,
SQL Server, and Oracle, are discussed. The basic ideas and implementation examples of DataTable
and DataSet are also analyzed and described with some real coding examples.
●● Chapter 4 provides detailed discussions and analyses about the Language-Integrated Query
(LINQ), which includes LINQ to Objects, LINQ to DataSet, LINQ to Entities, and LINQ to XML.
An introduction to LINQ general programming guide is provided in the first part of this chapter.
Some popular interfaces widely used in LINQ, such as IEnumerable, IEnumerable(Of T),
IQueryable and IQueryable(Of T), and Standard Query Operators (SQO) including the deferred
and non-deferred SQO, are also discussed in that part. An introduction to LINQ Query is given
in the second section of this chapter. Following this introduction, a detailed discussion and anal-
ysis about the LINQ queries that are implemented for different data sources is provided in detail
with quite a few example projects.
●● Starting from Chapter 5, the real database programming techniques with Visual Basic.NET such
as data selection queries are provided and discussed. Two parts are covered in this chapter: Part
I contains the detailed descriptions in how to develop professional data-driven applications with
the help of the Visual Studio.NET design tools and wizards with some real projects. This part
contains a lot of hiding codes that are created by Visual Basic.NET automatically when using
those design tools and wizards. Therefore, the coding job for this part is very simple and easy.
Part II covers an advanced technique, the runtime object method, in developing and building
professional data-driven applications. Detailed discussions and descriptions about how to build
professional and practical database applications using this runtime object method are provided
combined with four (4) real projects.
●● Chapter 6 provides detailed discussions and analyses about three popular data insertion meth-
ods with Oracle XE 18c database:
1) Using TableAdapter’s DBDirect methods TableAdapter.Insert() method.
2) Using the TableAdapter’s Update() method to insert new records that have already been
added into the DataTable in the DataSet.
3) Using the Command object’s ExecuteNonQuery() method.
This chapter is also divided into two parts: Methods 1 and 2 are related to Visual Studio.NET
design tools and wizards and therefore are covered in Part I. The third method is related to runt-
ime object and therefore it is covered in Part II. Four (4) real projects are used to illustrate how
to perform the data insertion into the Oracle XE 18c database. Some professional and practical
data validation methods are also discussed in this chapter to confirm the data insertion.
●● Chapter 7 provides discussions and analyses on three popular data updating and deleting meth-
ods with four real project examples:
1) Using TableAdapter DBDirect methods such as TableAdapter.Update() and TableAdapter.
Delete() to update and delete data directly again in the databases.
2) Using TableAdapter.Update() method to update and execute the associated TableAdapter’s
properties such as UpdateCommand or DeleteCommand to save changes made for the table
in the DataSet to the table in the database.
4 1 Introduction
3) Using the runtime object method to develop and execute the Command’s method
ExecuteNonQuery() to update or delete data again in the database directly.
This chapter is also divided into two parts: Methods 1 and 2 are related to Visual Studio.NET
design tools and wizards and therefore are covered in Part I. The third method is related to runt-
ime object and it is covered in Part II. Four (4) real projects are used to illustrate how to perform
the data updating and deleting against the database Oracle XE 18c. Some professional and prac-
tical data validation methods are also discussed in this chapter to confirm the data updating and
deleting actions. The key points in performing the data updating and deleting actions against a
relational database, such as the order to execute data updating and deleting between the parent
and child tables, are also discussed and analyzed.
●● Chapter 8 provides introductions and discussions about the developments and implementations
of ASP.NET Web applications in Visual Basic.NET 2019 environment. At the beginning of
Chapter 8, a detailed and complete description about the ASP.NET and the .NET Framework is
provided, and this part is especially useful and important to students or programmers who do
not have any knowledge or background in the Web application developments and implementa-
tions. Following the introduction section, a detailed discussion on how to install and configure
the environment to develop the ASP.NET Web applications is provided. Some essential tools
such as the Web server, IIS, and FrontPage Server Extension 2000 as well as the installation pro-
cess of these tools are introduced and discussed in detail. Starting from Section 8.3, the detailed
development and building process of ASP.NET Web applications to access the Oracle databases
are discussed with four (4) real Web application projects. One popular database Oracle XE 18c is
utilized as the target databases for those development and building processes.
●● Chapter 9 provides introductions and discussions about the developments and implementations
of ASP.NET Web services in Visual Basic.NET 2019 environment. A detailed discussion and
analysis about the structure and components of the Web services is provided at the beginning of
this chapter. One of the most popular databases, Oracle XE 18c, is discussed and used for three
kinds of example Web service projects, which include:
1) WebServiceOracleSelect
2) WebServiceOracleInsert
3) WebServiceOracleUpdateDelete
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 chap-
ter. Both Windows-based and Web-based Web service client projects are discussed and built for
each kind of Web services listed earlier. Totally, nine (9) projects, including the Web service and the
associated Web service client projects, are developed in this chapter. All projects have been
debugged and tested and can be run in most popular Windows compatible operating systems, such
as Windows XP, Windows 7/8, and Windows 10.
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 programming with
Visual Basic.NET and professional database programmers who has professional experience on
this topic.
1.4 How This Book Is Organized and How to Use This Boo 5
Level I
Chapter 2 Level II
Part I Part II
Chapter 5 Chapter 5
Part I Part II
Chapter 6 Chapter 6
Part I Part II
Chapter 7 Chapter 7
Optional
Chapter 8 Chapter 8
Chapter 9 Chapter 9
Chapters 2~4 provide the fundamentals on database structures and components, ADO.NET
and LINQ components. Chapters 5~7 each is divided into two parts: fundamental part and
advanced part. The data-driven applications developed with design tools and wizards provided
by Visual Studio.NET, which can be considered as the fundamental part, have less coding loads
and therefore they are more suitable to students or programmers who are new to the database
programming with Visual Basic.NET. Part II contains the runtime object method and it covers a
lot of coding developments to perform the different data actions against the database, and this
method is more flexible and convenient to experienced programmers even a lot of coding jobs is
concerned.
Chapters 8 and 9 give a full discussion and analysis about the developments and implementa-
tions of ASP.NET Web applications and Web services. These technologies are necessary to students
and programmers who want to develop and build Web applications and Web services to access and
manipulate data via Internet.
Based on the organization of this book we described earlier, this book can be used as two catego-
ries such as Level I and Level II, which is shown in Figure 1.1.
For undergraduate college students or beginning software programmers, it is highly recom-
mended to learn and understand the contents of Chapters 2~4 and Part I of Chapters 5~7, since
those are fundamental knowledge and techniques in database programming with Visual Basic.
NET. Regarding Chapters 8 and 9, it is optional to instructors and it depends on the time and
schedule available to instructors.
For experienced college students or software programmers who have already had some knowl-
edge and techniques in database programming, it is recommended to learn and understand the
contents of Part II of Chapters 5~7 as well as Chapters 8 and 9 since the runtime objects method
and some sophisticated database programming techniques, such as joined-table query and nested
stored procedures, are discussed and illustrated in those chapters with real examples. Also the ASP.
NET Web applications and ASP.NET Web services are discussed and analyzed with many real data-
base program examples for Oracle XE 18c database.
6 1 Introduction
Totally, nine (9) Appendices, Appendices A~I, are provided with the book to assist and help readers
to easily and correctly download and install all required and necessary software and tools to build
desired practical database projects. These Appendices provide crystal clear directions for readers to
enable them to smoothly go through the entire installing and setup processes for each kind of soft-
ware and development tool and make them ready to be used to build professional and practical
database applications. The main functions and directions provided by these Appendices include:
–– Appendix A: Download and Install Oracle Database 18c XE. Provides a
complete and accurate direction to help users to complete downloading and installing this
Oracle XE 18c Database with its engine.
–– Appendix B: Download and Install Oracle SQL Developer. Provides an
accurate direction to help users to complete downloading and installing this Oracle SQL
Developer. This tool is a key component to build and develop any customer Oracle database,
including our sample database CSE_DEPT with five data tables and keys.
–– Appendix C: Download and Install DevExpress WinForms. Provides a com-
plete direction to help users to complete downloading and installing this third-party tool. By
using this tool, users can directly and conveniently insert any image into any table in Oracle
database without any coding process. This product is a 30-day free trial version without any
charge to the user.
–– Appendix D: How to Use the Sample Database. To assist readers to quickly and
easily build professional database application projects, a sample database, CSE_DEPT, is pro-
vided and used for entire book. This sample database is used to simulate a computer science
and engineering department with five tables, LogIn, Faculty, Course, Student,
and StudentCourse. This Appendix provides a clear picture to show readers how to down-
load and duplicate this sample database in just some button clicks. Indeed, by using this
Appendix and following up the directions, one can easily and quickly build this sample data-
base without spending much time and efforts! It greatly simplifies the generation and building
process of this sample database and therefore provides a quick shortcut for readers.
–– Appendix E: How to Export the Sample Database. Opposite to Appendix D,
this Appendix provides a way to show readers how to export our sample database CSE_DEPT
to enable other users to import it to their blank database to simplify this database-building
process. By following up the directions provided by this Appendix, readers can easily and
quickly export their database to enable other users to import and make that database as their
database. How easy it is!
–– Appendix F: Download and Install dotConnect Express. This is a free-ver-
sion third-party product that provides a data drive for Oracle data provider. To access an Oracle
database from any programming environment, including Visual Basic.NET, a data drive is
necessary to work as a translator or a bridge to setup up a connection between Visual Basic.
NET and Oracle database engine. This Appendix provides a clear and complete direction to
enable readers to quickly setup this connection.
–– Appendix G: How to Use User-Defined Windows/Web Forms. To assist readers
to speed up their database project developments, all Windows Forms and Web Pages used for
all projects built in this book have been developed. Readers can use any of them by just simply
adding them into their projects by using Add|Existing Item menu item. All built
Windows Forms, including the LogIn Form, Selection Form, Faculty Form,
1.5 How to Use Appendices and Related Material 7
Course Form, and Student Form, and all built Web Pages, including the LogIn Page,
Selection Page, Faculty Page, Course Page, and Student Page, can be found from a folder VB
Forms\Windows and VB Forms\Web, which is located under the Students folder at the
Wiley ftp site (refer to Figure 1.2).
–– Appendix H: Download and Install FrontPage Server Extension for Windows 10.
To run any project developed in Chapters 8 and 9, one needs to use Internet Information Services
(IIS) provider. The FrontPage Server Extension can be considered as an administrator for IIS. To uti-
lize the IIS more effectively and efficiently, it is recommend installing this extension if possible.
For instructors:
For students:
Class DB projects
All source codes in each project developed in this book are available and open to publics, and all
projects are categorized and stored into the associated chapters, which are located at a folder
Class DB Projects that is under the Students folder at the Wiley ftp site www.wiley.com/
go/bai-VB-Oracle. You can copy or download those codes into your computer and run each project
as you like. To successfully run those projects, the following conditions must be met:
●● Visual Studio.NET 2019 or higher must be installed in your computer.
●● The database management system, Oracle Database Configuration Assistant,
must be installed in your computer.
●● The sample database, CSE_DEPT, must be installed in your computer in the appropriate
folders.
●● To run projects developed in Chapters 8 and 9, in addition to conditions listed above, an Internet
Information Services (IIS) such as FrontPage Server Extension 2000 or 2002 must be installed in
your computer and it works as a pseudo server for those projects.
●● Some third-party drives and tools, such as DevExpress WinForms, dotConnect for Oracle,
LinqConnect Express, and Oracle SQL Developer, should have been installed in your computer.
All related teaching and learning materials, including the sample database, example projects,
homework solutions, faculty and student images, as well as sample Windows forms and Web
pages, can be found from the associated folders, Instructors or Students, located at the
Wiley ftp site www.wiley.com/go/bai-VB-Oracle, as shown in Figure 1.2.
These materials are categorized and stored at different folders in two different sites based on the
teaching purpose (for instructors) and learning purpose (for students):
1) Sample Database Folder: Contains our sample database, CSE_DEPT (Oracle XE 18c) with
five (5) tables. Refer to Appendix D to get details in how to use this database for your applica-
tions or sample projects.
2) Class DB Projects Folder: Contains all sample projects developed in the book. Projects are
categorized and stored at different Chapter subfolder based on the book chapter sequence.
Readers can directly use the codes and GUIs of those projects by downloading them from this
folder that is located under the Students folder at the Wiley ftp site.
3) Images Folder: Contains all sample faculty image files (under the Images\Faculty sub-
folder) and all student image files (under the Images\Students subfolder) used in all sample
projects in the book. Readers can copy and paste those image files to their projects to use them.
4) VB Forms Folder: Contains all sampled Windows-based Forms (under the VB Forms\
Window subfolder) and Web-based Pages (under the VB Forms\Web subfolder) developed
and implemented in all sample projects in the book. Readers can use those Forms or Pages by
1.7 Instructors and Customer Support 9
adding them into their real projects with the Add|Existing Item menu item in the Visual
Studio.NET environment.
5) Teaching-PPT Folder: Contains all MS-PPT teaching slides for each chapter.
6) HW Question Solutions Folder: Contains selected solutions for the homework
Questions developed and used in the book. The solutions are categorized and stored at the dif-
ferent Chapter subfolder based on the book chapter sequence.
7) HW DB Project Solutions Folder: Contains all solutions for the homework Exercises
developed and used in the book. The project solutions are categorized and stored at the different
Chapter subfolder based on the book chapter sequence.
Folders 1~4 belong to learning materials for students; therefore, they are located at the sub-
folder Students at the site: www.wiley.com/go/bai-VB-Oracle. Folders 1~3 and 5~7 belong to
teaching materials for instructors, they are located at the sub-folder Instructors at the same
site (password protected) and available upon requests by instructors.
The teaching materials for all chapters have been extracted and represented by a sequence of
Microsoft Power Point files, each file for one chapter. The interested instructors can find them from
the folder Teaching-PPT that is located at a sub-folder Instructors at the site www.wiley.
com/go/bai-VB-Oracle and those instructor materials are available upon request from the book’s
listing on that site (password protected).
A selected homework Questions solution and all homework Exercise solutions are also available
upon request from the site. E-mail support is available to readers of this book. When you send
e-mail to us, please provide the following information:
●● The detailed description about your problems, including the error message and debug message,
as well as the error or debug number if it is provided.
●● Your name, job title, and company name.
●● Please send all questions to the e-mail address: ybai@jcsu.edu.
Detailed structure and distribution of all book-related materials in the Wiley site, including the
teaching and learning materials, are shown in Figure 1.2.
All projects in the folder Instructors|HW DB Project Solutions are different from
those in the Students folder since the former contained solutions to projects in the Exercises
part, but the latter have no solutions.
10
Introduction to Databases
Ying Bai and Satish Bhalla
Databases have become an integral part of our modern day life. Today, we are an information-driven
society. Large amounts of data are generated, analyzed, and converted into different information
at each moment. A recent example of biological data generation is the Human Genome project
that was jointly sponsored by the Department of Energy (DOE) and the National Institute of
Health (NIH). Many countries participated in this venture for more than 10 years. The project was
a tremendous success. It was completed in 2003 and resulted in the generation of huge amount of
genome data, currently stored in databases around the world. The scientists will be analyzing this
data in years to come.
Database technology has a direct impact on our daily lives. Decisions are routinely made by
organizations based on the information collected and stored in the databases. A record company
may decide to market certain albums in selected regions based on the music preference of teenag-
ers. Grocery stores display more popular items at the eye level, and reorders are based on the inven-
tories taken at regular intervals. Other examples include book orders by the libraries, club
memberships, auto part orders, winter cloth stock by department stores, and many others.
Database management programs have been in existence since the sixties. However, it was not
until the seventies when E. F. Codd proposed the then revolutionary Relational Data Model that
database technology really took off. In the early eighties, it received a further boost with the arrival
of personal computers and microcomputer-based data management programs like dBase II (later
followed by dBase III and IV). Today, we have a plethora of vastly improved programs for PCs and
mainframe computers, including Microsoft Access, SQL Server, IBM DB2, Oracle, Sequel Server,
MySQL, and others.
This chapter covers the basic concepts of database design followed by implementation of a spe-
cific relational database to illustrate the concepts discussed here. The sample database, CSE_DEPT,
is used as a running example. The database structure is shown by using Microsoft Access, Microsoft
SQL Server, and Oracle databases with a real Oracle 18c XE database sample in details. The topics
discussed in this chapter include:
●● What are databases and database programs?
–– File Processing System
–– Integrated Databases
●● Various approaches to developing a Database
●● Relational Data Model and Entity-Relationship (ER) Model
Oracle Database Programming with Visual Basic.NET: Concepts, Designs, and Implementations, First Edition. Ying Bai.
© 2021 The Institute of Electrical and Electronics Engineers, Inc. Published 2021 by John Wiley & Sons, Inc.
Companion website: www.wiley.com/go/bai-VB-Oracle
2.1 What Are Databases and Database Programs 11
●● Identifying Keys
–– Primary Keys, Foreign Keys, and Referential Integrity
●● Defining Relationships
●● Normalizing the Data
●● Implementing the Relational Sample Database
–– Create Microsoft SQL Server 2017 Express Sample Database
A modern day database is a structured collection of data stored in a computer. The term structured
implies that each record in the database is stored in a certain format. For example, all entries in a
phone book are arranged in a similar fashion. Each entry contains a name, an address, and a telephone
number of a subscriber. This information can be queried and manipulated by database programs. The
data retrieved in answer to queries becomes information that can be used to make decisions. The data-
bases may consist of a single table or related multiple tables. The computer programs used to create,
manage, and query databases are known as a DataBase Management Systems (DBMSs). Similar to the
databases, the DBMSs vary in complexity. Depending on the need of a user, one can use either a simple
application or a robust program. Some examples of these programs were given earlier.
within the database. A set of sophisticated programs known as DBMS is used to store, access, and
manipulate the data in the database. Details of data storage and maintenance are hidden from the
user. The user interacts with the database through the DBMS. A user may interact either directly
with the DBMS or via a program written in a programming language such as Visual C++, Java,
Visual Basic, or Visual C#. Only the DBMS can access the database. Large organizations employ
Database Administrators (DBA’s) to design and maintain large databases.
There are many advantages of using an integrated database approach over that of a file processing
approach:
1) Data sharing: The data in the database is available to a large numbers of users who can access
the data simultaneously and create reports and manipulate the data given proper authorization
and rights.
2) Minimizing data redundancy: Since all the related data exists in a single database, there is a
minimal need of data duplication. The duplication is needed to maintain relationship between
various data items.
3) Data consistency and data integrity: Reducing data redundancy will lead to data consist-
ency. Since data is stored in a single database, enforcing data integrity becomes much easier.
Furthermore, the inherent functions of the DBMS can be used to enforce the integrity with
minimum programming.
4) Enforcing standards: DBAs are charged with enforcing standards in an organization. DBA
takes into account the needs of various departments and balances it against the overall need of
the organization. DBA defines various rules such as documentation standards, naming conven-
tions, update and recovery procedures etc. It is relatively easy to enforce these rules in a Database
System, since it is a single set of programs which is always interacting with the data files.
5) Improving security: Security is achieved through various means such as controlling access to
the database through passwords, providing various levels of authorizations, data encryption,
providing access to restricted views of the database etc.
6) Data independence: Providing data independence is a major objective for any database system.
Data independence implies that even if the physical structure of a database changes, the applica-
tions are allowed to access the database as before the changes were implemented. In other words,
the applications are immune to the changes in the physical representation and access techniques.
The downside of using an integrated database approach has mainly to do with exorbitant costs
associated with it. The hardware, the software, and maintenance are expensive. Providing security,
concurrency, integrity, and recovery may add further to this cost. Furthermore, since DBMS
consists of a complex set of programs, trained personnel are needed to maintain it.
2.2 Develop a Database
Database development process may follow a classical Systems Development Life Cycle.
1) Problem Identification – Interview the user, identify user requirements, and perform pre-
liminary analysis of user needs.
2) Project Planning – Identify alternative approaches to solving the problem. Does the project
need a database? If so define the problem. Establish scope of the project.
3) Problem Analysis – Identify specifications for the problem. Confirm the feasibility of the pro-
ject. Specify detailed requirements
2.3 Sample Databas 13
2.3 Sample Database
We will use a sample database CSE_DEPT to illustrate some essential database concepts.
Tables 2.1~2.5 show sample data tables stored in this database.
The data in CSE_DEPT database is stored in five tables – LogIn, Faculty, Course, Student, and
StudentCourse. A table consists of row and columns (Figure 2.1). A row represents a record, and
the column represents a field. Row is called a tuple, and a column is called an attribute. For exam-
ple, Student table has seven columns or fields – student_id, name, gpa, major, schoolYear, and
email. It has five records or rows.
A78835 Andrew Woods 3.26 108 Computer Science Senior awoods@college.edu NULL
A97850 Ashly Jade 3.57 116 Information System Junior ajade@college.edu NULL
Engineering
B92996 Blue Valley 3.52 102 Computer Science Senior bvalley@college.edu NULL
H10210 Holes Smith 3.87 78 Computer Sophomore hsmith@college.edu NULL
Engineering
T77896 Tom Erica 3.95 127 Computer Science Senior terica@college.edu NULL
Table
Field
the database as made up of relations, a database jargon for tables. It is imperative that all data
elements in the tables are represented correctly. In order to achieve these goals, designers use
various tools. The most commonly used tool is ER Model. A well-planned model will give con-
sistent results and will allow changes if needed later on. Following section further elaborates on
the ER Model.
2.3.2.1 Entities
An entity is a data object, either real or abstract, about which we want to collect information. For
example, we may want to collect information about a person, a place, or a thing. An entity in an ER
diagram translates into a table. It should preferably be referred to as an entity set. Some common
examples are departments, courses, and students. A single occurrence of an entity is an instance.
There are four entities in the CSE_Dept database, LogIn, Faculty, Course, and Student. Each entity
is translated into a table with the same name. An instance of the Faculty entity will be Alice Brown
and her attributes.
2.3.2.2 Relationships
A database is made up of related entities. There is a natural association between the entities; it is
referred to as relationship. For example,
●● Students take courses
●● Departments offer certain courses
●● Employees are assigned to departments
18 2 Introduction to Databases
The number of occurrences of one entity associated with single occurrence of a related entity is
referred to as cardinality.
2.3.2.3 Attributes
Each entity has properties or values called attributes associated with it. The attributes of an entity
map into fields in a table. Database Processing is one attribute of an entity called Courses. The
domain of an attribute is a set of all possible values from which an attribute can derive its value.
2.4 Identifying Keys
2.5 Define Relationships
2.5.1 Connectivity
Connectivity refers to the types of relationships that entities can have. Basically, it can be one-
to-one, one-to-many, and many-to-many. In ER diagrams, these are indicated by placing 1, M or
N at one of the two ends of the relationship diagram. Figure illustrates the use of this
notation.
Table 2.7 Course (Partial data shown); Faculty (Partial data shown).
●● A one-to-one (1 : 1) relationship occurs when one instance of entity A is related to only one
instance of entity B. For example, user_name in the LogIn table and user_name in the Student
table (Figure 2.2).
●● A one-to-many (1 : M) relationship occurs when one instance of entity A is associated with
zero, one, or many instances of entity B. However, entity B is associated with only one instance
of entity A. For example, one department can have many faculty members; each faculty member
is assigned to only one department. In CSE_DEPT database, One-to-many relationship is repre-
sented by faculty_id in the Faculty table and faculty_id in the Course table, student_id in the
Student table and student_id in the StudentCourse table, course_id in the Course table and
course_id in the StudentCourse table (Figure 2.3).
●● A many-to-many (M : N) relationship occurs when one instance of entity A is associated with
zero, one, or many instances of entity B. And one instance of entity B is associated with zero,
one, or many instance of entity A. For example, a student may take many courses, and one
course may be taken by more than one student (Figure 2.4).
In CSE_DEPT database, a many-to-many relationship can be realized by using the third table.
For example, in this case, the StudentCourse that works as the third table set a many-to-many
relationship between the Student and the Course tables.
This database design assumes that the course table only contains courses taught by all faculty
members in this department for one semester. Therefore, each course can only be taught by a
unique faculty. If one wants to develop a Course table that contains courses taught by all faculty in
more than one semester, the third table, say FacultyCourse table, should be created to set up a
many-to-many relationship between the Faculty and the Course table since one course may be
taught by the different faculty for the different semester.
LogIn Student
user_name pass_word user_name gpa credits student_id
ajade tryagain ajade 3.26 108 A97850
awoods smart awoods 3.57 116 A78835
bvalley see
bvalley 3.52 102 B92996
hsmith try
hsmith 3.87 78 H10210
terica excellent
terica 3.95 127 T77896
Figure 2.2 One-to-one relationship in the LogIn and the Student tables.
Faculty Course
faculty_id faculty_name office course_id course faculty_id
A52990 Black Anderson MTC-218 CSC-132A Introduction to Programming J33486
A77587 Debby Angles MTC-320 CSC-132B Introduction to Programming B78880
B66750 Alice Brown MTC-257 CSC-230 Algorithms & Structures A77587
B78880 Ying Bai MTC-211 CSC-232A Programming I B66750
B86590 Davis Bhalla MTC-214 CSC-232B Programming I A77587
H99118 Jeff Henry MTC-336 CSC-233A Introduction to Algorithms H99118
J33486 Steve Johnson MTC-118 CSC-233B Introduction to Algorithms K69880
K69880 Jenney King MTC-324 CSC-234A Data Structure & Algorithms B78880
After three days and nights in the train it was pleasant to make a
halt at Tashkent, the capital of Russian Turkestan, though the
sudden change of climate was somewhat exhausting. It was towards
the end of March, and the whole town, famous for its fruit trees, was
embowered in pink and white blossom, and the avenues of
magnificent poplars, willows and beautiful Turkestan elms were
shaking out their fresh green leaves.
The Russians, under General Kaufmann, took Tashkent about fifty
years ago, and have laid out the new town with broad roads planted
with fine trees that are watered by irrigation. There are churches,
public parks, tram-lines and imposing-looking shops, the
considerable Russian population appearing to mix freely with the
Sarts, as the inhabitants are termed by the dominant race. In India a
white woman of whatever class has a position with the natives, but
here the ordinary Russian woman is seemingly on an equality with
them, and not infrequently marries them. In the best confectioner’s
shop, served by Russian girls, natives came in and bought and ate
cakes and sweets on the premises, side by side with smart officers
or elegant ladies evidently belonging to the upper circles of Tashkent
society.
Even in this remote part of the Russian Empire the War was brought
home to the inhabitants by the presence of fifteen thousand
prisoners, Germans and Austrians. The latter, who were mostly
Slavs, had the privilege of shopping in the town, and we heard that
they were on excellent terms with their captors, whereas the
Germans were permitted no such relaxation of their captivity.
A long narrow street led from the Russian city straight into the native
town with its mud-built houses, its little stalls of food and clothing, its
mosques and shrines, and above all its gaily clad populace. But for
the people I could have imagined myself to be in a Persian city; but
here, instead of men in dingily coloured frock-coats and tall
astrakhan hats, and women shrouded in black from head to foot, the
inhabitants of both sexes revelled in colour. All wore smart velvet or
embroidered caps, round which the greybeards swathed snowy
turbans. The men had striped coats of many colours, the brighter the
better, the little girls rivalling them with bold contrasts, such as a
short, gold-laced magenta velvet jacket worn above a flowered,
scarlet cotton skirt, or a coat of emerald green with a vivid blue
under-garment. For the most part they were pretty, rosy-cheeked,
velvet-eyed maidens, with their hair hanging down their backs in a
dozen plaits, and I felt sorry to think that all their charm would shortly
have to disappear behind the long cloak, beautifully embroidered
though it might be, and the hideous black horsehair veil affected by
their mothers.
One fascinating little figure adorned with big earrings and bracelets
came dancing down an alley into the street, holding out the ends of a
scarlet veil which she had thrown over her head, her cotton dress
and trousers being in two shades of rose. She pirouetted up to a tall
man in a rainbow-coloured silk coat who was carrying a tin can, and
had paused at the steps of the mosque to let the children gather
round him. To my surprise he began to dole out ice-cream in little
glasses, and boys and girls had delicious “licks” in exchange for
small coins. I remembered how envious I had felt in early youth
when I saw English street urchins partaking of what seemed to me to
be food fit for the gods, although my nurse allowed me no chance of
sampling it, and in a moment the East and the West seemed to
come very near, the ice-cream man acting as the bridge across the
gulf.
After leaving Tashkent we travelled through a rich alluvial country
watered by the Sir Daria, the classical Jaxartes, and halted on our
way to Andijan at the ancient city of Khokand. As at Tashkent, the
Russian and native towns are separate, and we hired a moon-faced,
beardless Sart, attired in a long red and blue striped coat and with an
embroidered skull-cap perched on his shaven head, to drive us
round.
He raced his wiry little ponies at a great pace along a wide tree-
planted avenue ending in a church of preternatural ugliness set in a
public garden. Near by were Russian houses and shops, while small
victorias containing grey-uniformed officers or turbaned Sarts
dashed past, and native carts laden with bales of cotton creaked
slowly by. Many of these carts had big tilts, the wooden framework
inside being gaudily painted, and the horses themselves were
decked with handsome brass trappings.
The old town, with its high mud walls, flat-roofed squalid dwellings, a
bazar closely resembling those to be found in any Asiatic city, and
comparatively modern mosques, had little of interest, though a well-
known traveller speaks of its thirty-five theological colleges: its roads,
as usual, were bad and narrow, and must be rivers of mud in wet
weather.
Many women were unveiled, others wore the ghoul-like horsehair
face coverings, and some of their embroidered coats were so
charming in design and colouring that I longed to do a “deal” with the
wearers. Many of the people were squatting, eating melons which
they store during the winter, or drinking tea, a Russian woman being
evidently a member of one family group. We had one or two narrow
shaves of colliding with other carriages, as our coachman threaded
his way far too fast for safety and exchanged abusive epithets with
his brother Jehus, among whom were Russians in black, sleeveless,
cassock-like garments worn over scarlet cotton blouses. The
harness of the little horses was adorned with many tufts of coloured
wools, giving a pretty effect as these tassels nearly swept the ground
or waved in the air. The life on the roads, the spring sunshine, the
fresh green leaves, the white and pink of the blossom, and the orgy
of colour furnished by the inhabitants, made the drive an
unforgettable experience.
A few hours later we reached Andijan, where the railway ended, and
here we had our last clean resting-place until we arrived at Kashgar.
I noticed that the native women wore long grey burnouses with black
borders ending in two tails that were always trailing in the dust, and
all hid their faces in the mask-like horsehair veils. It was the day
before Palm Sunday, and as we strolled in the evening up the
cobbled street of the town a large congregation was issuing from the
church, every one carrying a small branch and a little candle, which
each had lit in the sanctuary. In the darkness the scores of tiny lights
looked like fire-flies, and I observed how carefully the sacred flame
was sheltered from any draught, as it is considered most important
to convey it home unextinguished. Our hotel was fairly good, but I
was not pleased on retiring to find that my door did not lock, and that
my window, opening on to a public balcony, had no fastening. To
supplement these casual arrangements I made various “booby-
traps” by which I should be awakened if any robber entered my
room, but luckily slept undisturbed.
It may give some idea of the vast extent of the plains of Russia
which we had crossed by train, when I mention that there was not a
single tunnel on the hundreds of miles of rail between Petrograd and
Andijan.
It was the end of March when we set out to drive the thirty miles from
Andijan to Osh. We packed ourselves, our suit-cases and the lunch-
basket into a little victoria, while Achmet, the Russian Tartar cook we
had engaged at Tashkent, accompanied our heavy baggage in the
diligence. The sky was overcast with heavy clouds, so there was no
glare from the sun, and the rain of the previous night had laid the
dust on the broad road full of ruts and holes. Ploughing was in full
swing, barley some inches high in the fields, fruit blossom
everywhere, and the poplars and willows planted along the countless
irrigation channels made a delicate veil of pale green. Beyond the
cultivation lay bare rolling hills, behind which rose the lofty mountain
ranges which we must cross before we could reach our destination.
The whole country seemed thickly populated, and we passed
through village after village teeming with life, the source of which is
the river, which ran at this time of year in a surprisingly narrow
stream in its broad pebbled bed, and was so shallow that men on
foot or on donkey-back were perpetually crossing it. Tortoises were
emerging from their winter seclusion, the croak of the frog filled the
land, hoopoes and the pretty doves which are semi-sacred and
never molested flew about, and the ringing cry of quail and partridge
sounded from cages in which the birds were kept as pets.
The men, if not busied with agriculture, were usually fast asleep or
drinking tea on the mud platforms in front of their dwellings, and the
gaily clad women slipped furtively from house to house, or, if riding,
sat on a pillion behind the men. In fine contrast to her veiled sisters
was a handsome Kirghiz lady following her husband on horseback
through the Osh bazar, and making a striking figure in a long green
coat, her head and chin wrapped in folds of white that left her
massive earrings exposed to view. She rode astride every whit as
well as the man did, exchanged remarks freely with him, and was
moreover holding her child before her on the saddle. Other women
were carrying cradles which must have made riding difficult, and
often a child stood behind, clinging to its mother’s shoulders. On
entering the native town of Osh, mentioned in Baber’s Memoirs as
being unsurpassed for healthiness and beauty of situation, we
passed a mosque with such a badly constructed mud dome that it
looked like a turnip, and made our way along a broad tree-planted
Russian road to the nomera. This was a house with “furnished
apartments to let,” and the small rooms, by no means overclean,
were supplied with beds, tables and chairs. We set to work to
unpack our camp things, and sent Achmet out to buy bread, butter,
meat, eggs, etc., for our two hundred and sixty mile ride to Kashgar.
Our host made no pretensions to supply food, but exactly opposite
our lodgings was the officers’ mess; with true Russian hospitality its
members invited us to take our meals there, and next day at lunch
we met a dozen officers, with their jovial, long-haired chaplain in
black cassock with a broad silver chain and crucifix round his neck.
Luckily for me there were a couple of officers who spoke German,
though the others threatened them with heavy fines for daring to
converse in the language of the Huns. In spite of the Tsar’s edict,
vodka and wine flowed freely (the doctor had evidently given medical
certificates liberally to the mess) and numerous toasts were drunk,
every one clinking his glass with my brother’s and mine as the health
of King George, the Tsar, our journey, and so on were given. All were
most kind, though I could have wished Russian entertainments were
not so long—that luncheon lasted over three hours—and we left in a
chorus of good wishes for our ride to Kashgar.
We were roused early next morning by the arrival of our caravan of
small ponies, and with much quarrelling on the part of their drivers
the loads were at last adjusted. We had our saddles put on a couple
of ill-fed animals and started off beside the rushing river on our first
stage of twenty miles. The ponies were very inferior to the fine mules
with which we had travelled in Persia, and our particular steeds
would certainly have broken down long before we reached Kashgar
if we had not dismounted and walked at frequent intervals
throughout the whole journey.
At first the road was excellent as we left pretty little Osh nestling
under Baber’s “mountain of a beautiful figure,” and made our way up
a highly cultivated valley towards the distant snowy peaks. We were
escorted by a fine-looking Ming Bashi or “Commander of a
Thousand,” who had a broad velvet belt set with bosses and clasps
of handsome Bokhara silver-work. He wore the characteristic Kirghiz
headgear, a conical white felt with a turned-up black brim, and four
black stripes, from the back to the front and from side to side of the
brim, meeting at the top and finishing off with a black tassel. We
were to see this headgear constantly during the next eight months,
as it is worn throughout Chinese Turkestan and the Pamirs. Owing to
the presence of these Ming Bashis we met with extreme
consideration, village Begs and their servants escorting us at every
stage and securing the right of way for us with caravans. This was a
privilege that for my part I keenly appreciated, as the track, when it
skirted the flanks of the mountains, was hardly ever wide enough for
one animal to pass another, and I had no wish to be pushed out of
my saddle over the precipice by the great bales of cotton that formed
the load of most of the ponies we met. These officials usually
secured some garden or field, a place of trees and running water,
where we could lunch and rest at mid-day, and often they brought a
silken cushion which they offered to my brother. They were surprised
when he handed it on to me, for in Mohamedan countries the woman
is considered last—if at all.
In the Osh district horses, camels, donkeys, cows, goats and sheep
were in abundance, the sheep having the dumba or big bunch of fat
as a tail, which nourishes the animal when grass runs short during
the winter months. They had long hair like goats and rabbit-like ears,
were coloured black, white, brown, grey or buff, and looked far larger
in proportion than the undersized cattle and ponies. On the road we
saw many of the characteristic carts that had immensely high wheels
with prominent hubs. The driver sat on a saddle on the horse’s back,
supporting his feet on the shafts, thereby depriving the animal of half
its strength for pulling the load and proving that this nation of born
riders has not grasped the elementary principles of driving. These
carts had no sides, but carried their loads in a curious receptacle of
trellis-work, as shown in the illustration.