Oracle Database Programming with Visual Basic.NET: Concepts, Designs and Implementations Ying Baidownload
Oracle Database Programming with Visual Basic.NET: Concepts, Designs and Implementations Ying Baidownload
https://ebookmass.com/product/oracle-database-programming-with-
visual-basic-net-concepts-designs-and-implementations-ying-bai/
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/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
W oldemar – wie Rex seinem Freunde Czako, als beide über den
Cremmer Damm ritten, ganz richtig mitgeteilt hatte – verkehrte seit
Ausgang des Winters im Barbyschen Hause, das er sehr bald vor
andern Häusern seiner Bekanntschaft bevorzugte. Vieles war es, was
ihn da fesselte, voran die beiden Damen; aber auch der alte Graf. Er
fand Ähnlichkeiten, selbst in der äußern Erscheinung, zwischen dem
Grafen und seinem Papa, und in seinem Tagebuche, das er, trotz
sonstiger Modernität, in altmodischer Weise von jung an führte,
hatte er sich gleich am ersten Abend über eine gewisse
Verwandtschaft zwischen den beiden geäußert. Es hieß da unterm
achtzehnten April: »Ich kann Wedel nicht dankbar genug sein, mich
bei den Barbys eingeführt zu haben; alles, was er von dem Hause
gesagt, fand ich bestätigt. Diese Gräfin, wie charmant, und die
Schwester ebenso, trotzdem größere Gegensätze kaum denkbar
sind. An der einen alles Temperament und Anmut, an der andern
alles Charakter oder, wenn das zuviel gesagt sein sollte, Schlichtheit,
Festigkeit. Es bleibt mit den Namen doch eine eigene Sache; die
Gräfin ist ganz Melusine und die Komtesse ganz Armgard. Ich habe
bis jetzt freilich nur eine dieses Namens kennen gelernt, noch dazu
bloß als Bühnenfigur, und ich mußte beständig an diese denken, wie
sie da (ich glaube, es war Fräulein Stolberg, die ja auch das Maß
hat) dem Landvogt so mutig in den Zügel fällt. Ganz so wirkt
Komtesse Armgard! Ich möchte beinah sagen, es läßt sich an ihr
wahrnehmen, daß ihre Mutter eine richtige Schweizerin war. Und
dazu der alte Graf! Wie ein Zwillingsbruder von Papa; derselbe
Bismarckkopf, dasselbe humane Wesen, dieselbe Freundlichkeit,
dieselbe gute Laune. Papa ist aber ausgiebiger und auch wohl
origineller. Vielleicht hat der verschiedene Lebensgang diese
Verschiedenheiten erst geschaffen. Papa sitzt nun seit richtigen
dreißig Jahren in seinem Ruppiner Winkel fest, der Graf war
ebensolange draußen! Ein Botschaftsrat ist eben was anderes als ein
Ritterschaftsrat, und an der Themse wächst man sich anders aus als
am ›Stechlin‹ – unsern Stechlin dabei natürlich in Ehren. Trotzdem,
die Verwandtschaft bleibt. Und der alte Diener, den sie Jeserich
nennen, der ist nun schon ganz und gar unser Engelke vom Kopf bis
zur Zeh. Aber was am verwandtesten ist, das ist doch die gesamte
Hausatmosphäre, das Liberale. Papa selbst würde zwar darüber
lachen – er lacht über nichts so sehr wie über Liberalismus –, und
doch kenne ich keinen Menschen, der innerlich so frei wäre, wie
gerade mein guter Alter. Zugeben wird er's freilich nie und wird in
dem Glauben sterben: ›Morgen tragen sie einen echten alten Junker
zu Grabe.‹ Das ist er auch, aber doch auch wieder das volle
Gegenteil davon. Er hat keine Spur von Selbstsucht. Und diesen
schönen Zug (ach, so selten), den hat auch der alte Graf. Nebenher
freilich ist er Weltmann, und das gibt dann den Unterschied und das
Übergewicht. Er weiß – was sie hierzulande nicht wissen oder nicht
wissen wollen –, daß hinterm Berge auch noch Leute wohnen. Und
mitunter noch ganz andre.«
J a, der alte Graf war nicht bloß froh, die Wohnung zu haben, er
hielt auch beinah abergläubisch an ihr fest. So lange er darin
wohnte, war es ihm gut ergangen, nicht glänzender als früher, aber
sorgenloser. Und das sagte er sich jeden neuen Tag.
Sein Leben, so bunt es gewesen, war trotzdem in gewissem Sinne
durchschnittsmäßig verlaufen, ganz so wie das Leben eines
preußischen »Magnaten« (worunter man in der Regel Schlesier
versteht; aber es gibt doch auch andre) zu verlaufen pflegt.
Im Juli dreißig, gerade als die Franzosen Algier bomdardierten und
nebenher das Haus Bourbon endgültig beseitigten, war der Graf auf
einem der an der mittleren Elbe gelegenen Barbyschen Güter
geboren worden. Auf eben diesem Gute – das landwirtschaftlich
einer von fremder Hand geführten Administration unterstand –
vergingen ihm die Kinderjahre; mit zwölf kam er dann auf die
Ritterakademie, mit achtzehn in das Regiment Garde-du-Corps, drin
die Barbys standen, solang es ein Regiment Garde-du-Corps gab. Mit
dreißig war er Rittmeister und führte eine Schwadron. Aber nicht
lange mehr. Auf einem in der Nähe von Potsdam veranstalteten
Kavalleriemanöver stürzte er unglücklich und brach den
Oberschenkel, unmittelbar unter der Hüfte. Leidlich genesen, ging er
nach Ragaz, um dort völlige Wiederherstellung zu suchen, und
machte hier die Bekanntschaft eines alten Freiherrn von Planta, der
ihn alsbald auf seine Besitzungen einlud. Weil diese ganz in der Nähe
lagen, nahm er die Einladung nach Schloß Schuder an. Hier blieb er
länger als erwartet, und als er das schön gelegene Bergschloß
wieder verließ, war er mit der Tochter und Erbin des Hauses verlobt.
Es war eine große Neigung, was sie zusammenführte. Die junge
Freiin drang alsbald in ihn, den Dienst zu quittieren, und er
entsprach dem um so lieber, als er seiner völligen Wiederherstellung
nicht ganz sicher war. Er nahm also den Abschied und trat aus dem
militärischen in den diplomatischen Dienst über, wozu seine Bildung,
sein Vermögen, seine gesellschaftliche Stellung ihn gleichmäßig
geeignet erscheinen ließen. Noch im selben Jahre ging er nach
London, erst als Attaché, wurde dann Botschaftsrat und blieb in
dieser Stellung zunächst bis in die Tage der Aufrichtung des
Deutschen Reiches. Seine Beziehungen sowohl zu der heimisch-
englischen wie zu der außerenglischen Aristokratie waren jederzeit
die besten, und sein Freundschaftsverhältnis zu Baron und Baronin
Berchtesgaden entstammte jener Zeit. Er hing sehr an London. Das
englische Leben, an dem er manches, vor allem die geschraubte
Kirchlichkeit, beanstandete, war ihm trotzdem außerordentlich
sympathisch, und er hatte sich daran gewöhnt, sich als verwachsen
damit anzusehen. Auch seine Familie, die Frau und die zwei Töchter
– beide, wenn auch in großem Abstande, während der Londoner
Tage geboren – teilten des Vaters Vorliebe für England und
englisches Leben. Aber ein harter Schlag warf alles um, was der Graf
geplant: die Frau starb plötzlich, und der Aufenthalt an der ihm so
lieb gewordenen Stätte war ihm vergällt. Er nahm in der ersten
Hälfte der achtziger Jahre seine Demission, ging zunächst auf die
Plantaschen Güter nach Graubünden und dann weiter nach Süden,
um sich in Florenz seßhaft zu machen. Die Luft, die Kunst, die
Heiterkeit der Menschen, alles tat ihm hier wohl, und er fühlte, daß
er genas, soweit er wieder genesen konnte. Glückliche Tage brachen
für ihn an, und sein Glück schien sich noch steigern zu sollen, als
sich die ältere Tochter mit dem italienischen Grafen Ghiberti
verlobte. Die Hochzeit folgte beinah unmittelbar. Aber die Fortdauer
dieser Ehe stellte sich bald als eine Unmöglichkeit heraus, und ehe
ein Jahr um war, war die Scheidung ausgesprochen. Kurze Zeit
danach kehrte der Graf nach Deutschland zurück, das er, seit einem
Vierteljahrhundert, immer nur flüchtig und besuchsweise
wiedergesehen hatte. Sich auf das eine oder andere seiner Elbgüter
zu begeben, widerstand ihm auch jetzt noch, und so kam es, daß er
sich für Berlin entschied. Er nahm Wohnung am Kronprinzenufer und
lebte hier ganz sich, seinem Hause, seinen Töchtern. Von dem
Verkehr mit der großen Welt hielt er sich so weit wie möglich fern,
und nur ein kleiner Kreis von Freunden, darunter auch die durch
einen glücklichen Zufall ebenfalls von London nach Berlin
verschlagenen Berchtesgadens waren, versammelte sich um ihn.
Außer diesen alten Freunden waren es vorzugsweise Hofprediger
Frommel, Doktor Wrschowitz und seit letztem Frühjahr auch
Rittmeister von Stechlin, die den Barbyschen Kreis bildeten. An
Woldemar hatte man sich rasch attachiert, und die freundlichen
Gefühle, denen er bei dem alten Grafen sowohl wie bei den Töchtern
begegnete, wurden von allen Hausbewohnern geteilt. Selbst die
Hartwigs interessierten sich für den Rittmeister, und wenn er abends
an der Portierloge vorüberkam, guckte Hedwig neugierig durch das
Fensterchen und sagte: »So einen, – ja, das lass' ich mir gefallen.«
Dreizehntes Kapitel
N un war der andre Nachmittag da, und kurz vor vier Uhr fuhren
erst die Berchtesgadens und gleich danach auch die Barbys bei der
Jannowitzbrücke vor. Woldemar wartete schon. Alle waren in jener
heitern Stimmung, in der man geneigt ist, alles schön und reizend zu
finden. Und diese Stimmung kam denn auch gleich der
Dampfschiffahrtsstation zustatten. Unter lachender Bewunderung
der sich hier darbietenden Holzarchitektur stieg man ein Gewirr von
Stiegen und Treppen hinab und schritt, unten angekommen, an den
um diese Stunde noch leeren Tischen eines hier etablierten »Lokals«
vorüber, unmittelbar auf das Schiff zu, dessen Glocke schon zum
erstenmal geläutet hatte. Das Wetter war prachtvoll, flußaufwärts
alles klar und sonnig, während über der Stadt ein dünner Nebel lag.
Zu beiden Seiten des Hinterdecks nahm man auf Stühlen und
Bänken Platz und sah von hier aus auf das verschleierte Stadtbild
zurück.
»Da heißt es nun immer,« sagte Melusine, »Berlin sei so
kirchenarm; aber wir werden bald Köln und Mainz aus dem Felde
geschlagen haben. Ich sehe die Nikolaikirche, die Petrikirche, die
Waisenkirche, die Schloßkuppel, und das Dach da, mit einer Art von
chinesischer Deckelmütze, das ist, glaub ich, der Rathausturm. Aber
freilich, ich weiß nicht, ob ich den mitrechnen darf.«
»Turm ist Turm,« sagte die Baronin. »Das fehlte so gerade noch,
daß man dem armen alten Berlin auch seinen Rathausturm als Turm
abstritte. Man eifersüchtelt schon genug.«
Und nun schlug es vier. Von der Parochialkirche her klang das
Glockenspiel, die Schiffsglocke läutete dazwischen, und als diese
wieder schwieg, wurde das Brett aufgeklappt, und unter einem
schrillen Pfiff setzte sich der Dampfer auf das mittlere Brückenjoch
zu in Bewegung.
ebookmasss.com