Home > Store

Database Access with Visual Basic .NET, 3rd Edition

Register your product to gain access to bonus material or receive a coupon.

Database Access with Visual Basic .NET, 3rd Edition


  • Sorry, this book is no longer in print.
Not for Sale


  • Copyright 2003
  • Dimensions: 7-3/8" x 9-1/4"
  • Pages: 464
  • Edition: 3rd
  • Book
  • ISBN-10: 0-672-32343-5
  • ISBN-13: 978-0-672-32343-0

Whether you are using WinForms, WebForms, or Web Services, Database Access with Visual Basic® .NET, Third Edition, is your practical guide to developing database applications with Visual Basic .NET and ADO.NET. The authors provide real-world solutions to the data-access issues Visual Basic .NET developers face every day and share their secrets for becoming a more effective database programmer using .NET technologies.

The book begins by reviewing the fundamentals of database development, Structured Query Language (SQL), and Microsoft SQL Server™ 2000. It then examines how to use the major ADO.NET objects to access data stored in relational databases. Through detailed examples, readers learn how to use properties and methods, as well as more advanced features and techniques. Extensive code listings in Visual Basic .NET illustrate each concept, while business cases apply concepts to real-world applications. The final chapters provide a solid examination of how XML and ASP.NET integrate with ADO.NET to create various types of database applications. A companion Web site provides the code used in the book's myriad examples, all of which is compatible with Visual Basic .NET 2003.

Key topic coverage includes:

  • SQL queries and commands
  • Using SQL Server 2000
  • ADO.NET objects
  • Advanced ADO.NET features and techniques
  • SQL Server and OLEDB, as well as ODBC .NET Data Providers
  • Using Visual Studio .NET Data Projects for managing SQL Scripts
  • Integrating XML with ADO.NET
  • Developing Web-based database applications with ASP.NET
  • Web services and middle-tier objects
  • Database Access with Visual Basic® .NET, Third Edition, equips VB developers with the knowledge and skills needed to build a powerful new generation of database applications in less time using .NET technologies.



    Source Code

    Download the Source Code related to this title.


    Author's Site

    Untitled Document

    Click below for Web Resources related to this title:
    Author Web Site

    Sample Content

    Online Sample Chapter

    Visual Studio.NET Database Projects

    Downloadable Sample Chapter

    Click below for Sample Chapter(s) related to this title:
    Sample Chapter 8

    Table of Contents


    1. Database Basics.

    What Is a Database?

    What Is a Database Platform?

    Business Cases.

    Business Case 1.1: Introducing Jones Novelties, Incorporated.

    Tables and Fields.

    Designing Your Database.

    Business Case 1.2: Designing Tables and Relationships.

    Manipulating Data with Objects.

    Data Types.

    Creating a Database Schema.

    Using Visual Studio to Create a Database.

    Designating Indexes and the Primary Key.

    Creating Database Diagrams.

    Using Microsoft Visio to View and Alter a Database Schema.


    Using Referential Integrity to Maintain Consistency.

    Testing Referential Integrity Constraints, Using Server Explorer.

    Cascading Updates and Cascading Deletes.


    One-to-One Relationships.

    One-to-Many Relationships.

    Many-to-Many Relationships.

    Creating a User Interface in a Windows Forms Application.

    Connecting to a Database and Working with Records.

    Creating a Data Browser Application.

    Performing Binding Programmatically.

    About Data-Aware Controls in .NET.

    Updating Records in the Data Browser Application.

    Creating New Records in a Data-Bound Form.

    Deleting Records from a Data-Bound Form.

    Validating Data Entry in a Data-Bound Form.

    Validation at the Database Engine Level.


    Questions and Answers.

    2. Structured Query Language Queries and Commands.

    What is a Query?

    Testing Queries with the Server Explorer.

    Retrieving Records with the SELECT Clause.

    Designating a Record Source with the FROM Clause.

    Specifying Criteria with the WHERE Clause.

    Operators in WHERE Clauses.

    Sorting Results with ORDER BY.

    Sorting in Descending Order.

    Sorting on Multiple Fields.

    Displaying the Top or Bottom of a Range with TOP.

    Creating Top Percentage Queries.

    Joining Related Tables in a Query.

    Expressing a Join in SQL.

    Using Outer Joins to Return Additional Data.

    Performing Calculations in Queries.

    Aliasing Field Names with AS.

    Queries That Group and Summarize Data.

    Using HAVING to Provide Criteria for Grouped Queries.

    The SUM Function.

    Other SQL Aggregate Functions.

    Union Queries.


    Manipulating Data with SQL.

    Update Commands.

    Delete Commands.

    Insert Commands.

    Creating Tables with SELECT INTO.

    Using Data Definition Language.

    Creating Database Elements with CREATE.

    Adding Constraints to Tables.

    Creating Indexes with CREATE INDEX.

    Deleting Tables and Indexes with DROP.

    Modifying a Tables Definition with ALTER.


    Questions and Answers.

    3. Getting Started with SQL Server 2000.

    Setting Up and Running Microsoft SQL Server 2000.

    Determining Installation Requirements for SQL Server 2000.

    Installing SQL Server 2000.

    Starting and Stopping SQL Server with SQL Service Manager.

    Controlling the Way SQL Server Starts Up.

    Getting Started with SQL Server 2000: The Basics.

    Running SQL Server Enterprise Manager.

    Creating a Database with SQL Enterprise Manager.

    Creating Tables in a SQL Server Database.

    Using SQL Query Analyzer to Access a Database.

    Using Database Views to Control Access to Data.

    Creating and Running Stored Procedures.

    Displaying the Text of an Existing View or Stored Procedure.

    Creating Triggers.

    Business Case 3.1: Creating a Trigger That Enables Soundalike Searches.

    Managing Users and Security in SQL Server Enterprise Manager.

    Applying Security Attributes in SQL Query Analyzer.

    Removing Objects from the Database

    Business Case 3.2: Generating an SQL Script That Creates a Database.


    Questions and Answers.

    4. ADO.NETData Providers.

    Overview of ADO.NET.

    Motivation and Philosophy.

    ADO.NET Versus Classic ADO (2.x).

    ADO.NET Objects Within the .NET Framework.

    Application Interfaces.

    Overview of .NET Data Provider Objects.




    Core Objects.

    The Connection Object.

    The Command Object.

    Using the Command Object with Parameters and Stored Procedures.

    Executing the Commands.

    The DataReader Object.

    Using the Connection and Command Design-Time Components.

    Other Data Provider Objects.

    Business Case 4.1: Writing a Routine to Archive Old Orders by Year.


    Questions and Answers.

    5. ADO.NETThe DataSet.

    Applications and Components of the DataSet.

    Populating and Manipulating the DataSet.

    Defining DataTable Schemas.

    Adding Data to a DataTable.

    Updating the DataSet.

    Accessing Data from a DataTable.

    Table Relations.

    Table Constraints.

    Using the DataSet Component.


    Questions and Answers.

    6. ADO.NETThe DataAdapter.

    Populating a DataSet from a Data Source.

    Updating the Data Source.

    Setting the Update Commands.

    Business Case 6.1 Combining Multiple Related Tables.


    Questions and Answers.

    7. ADO.NETAdditional Features and Techniques.

    Detecting Concurrency Conflicts.

    Table and Column Mappings.


    Business Case 7.1: Viewing Data Combined from Different Sources.

    Strongly Typed DataSets.


    Questions and Answers.

    8. Visual Studio.NET Database Projects.

    Creating a Database Project.

    Database References.


    Create Scripts.

    Change Scripts.

    Running the Scripts.

    Command Files.



    Questions and Answers.

    9. XML and .NET.

    An Overview of XML.

    The XML Family of Technologies.

    XML and Data Access.

    XML Classes in .NET.

    Working with the Document Object Model.

    Working with XPATH.

    Extending SQL Server with SQLXML 3.0 and IIS.

    Installing and Configuring SQLXML 3.0.

    Configuration Results.

    Using XML, XSLT, and SQLXML to Create a Report.


    Questions and Answers.

    10. ADO.NET and XML.

    Basic Reading and Writing of XML.

    Reading XML.

    Writing XML.


    Business Case 10.1: Preparing XML Files for Business Partners.

    Creating an XmlReader from a Command Object.

    The XmlDataDocument Object.


    Questions and Answers.

    11. WebForms: Database Applications with ASP.NET.

    An Overview of ASP.NET.

    HTML Controls Versus Server Controls.

    Additional Highlights of ASP.NET.

    Accessing a Database Through ASP.NET.

    Adding the ASPNET User to the SQL Server Logins.


    Working with the DataGrid.

    Improving the Performance of ASP.NET Database Applications Through Stored Procedures.


    Questions and Answers.

    12. Web Services and Middle-Tier Technologies.

    Using the Middle Tier to Provide Presentation Logic.

    Using Data in the Middle Tier.

    Creating Reusable Middle-Tier Components.

    Using the Component from Another Application.

    Exposing Objects Through Web Services.

    Exposing an Existing Object Through a Web Service.

    Accessing Web Services Programmatically.

    Putting It All Together.


    Questions and Answers.

    Index. 0672323435T01242003


    The purpose of this book is to show you how to development database applications using Visual Basic .NET and ADO.NET.

    Although both the OLEDB and the ODBC Data Providers for .NET are discussed (Chapter 4), almost all of the examples in this book will be for Microsoft SQL Server 2000. This is because it is readily available and used by most of our readers. Moreover, applying the concepts and making the required code modifications for other data sources is normally very straightforward. We tried to point out where there are significant differences.

    Even though we expect that most readers will be working with SQL Server, we do not assume that they are experienced with it. This may be because they are new to database applications, or because they only have experience with other databases such as Microsoft Access or Oracle. We have therefore included a hefty overview of Microsoft SQL Server. If you are experienced with SQL Server, you may want to skip this chapter, although since it covers a wide variety of topics, you may still find a "nugget" or two that makes it worthwhile for you to read the chapter.

    Along with the coverage of database access using SQL Server, we have included coverage of XML and XML integration with ADO.NET. This is a crucial aspect of developing database applications with VB .NET that is often overlooked or short-changed. However since XML is so important to developing modern data-driven applications, we have provided rather extensive coverage of this topic.

    You will notice that this book contains a lot of code and examples. We believe that this is the best way to understand the concepts that are presented. We normally provide relatively simple examples to demonstrate the concepts, and then present Business Cases to put the concepts into a "real-world" context.

    Who This Book Is For

    We assume that the reader of this book is already familiar with Visual Basic .NET. Although the code examples code step-by-step instructions, this book does not teach VB .NET syntax. We assume that you are comfortable enough with VB .NET and Visual Studio .NET, and do not waste your time reviewing these concepts once again. For example, we will not normally step through basic tasks, such as opening and savings project files, except maybe the first time we encounter them. We will, however, often show how to do the same thing in several different ways—we hope that this will extend your knowledge of VB .NET, without rehashing the basics. To the same end, you may also notice variant coding styles, and even screen shots on different versions of Windows—all illustrating the flexibility of VB .NET.

    Most of the examples in this book are shown using Windows Application (Windows Forms) as the project type. This is because nearly all VB programmers are most familiar and comfortable with this type of application. This allows us to focus on database access, rather than the technologies involved in the different types of .NET projects. Still, in later chapters, we do discuss and show ASP.NET web applications and web services, so that you see database access examples using these technologies and project types.

    How This Book Is Organized

    This book can be though of as containing three parts. The first part, consisting of Chapters 1-3, are the "preliminaries". The coverage of database basics, SQL, and SQL Server are meant to provide the fundamentals required to proceed comfortably throughout the rest of the book. At the same time, these chapters provide a good review of these topics even for someone who is experienced is these areas.

    The second part could be thought of as the core of the book. Chapters 4-7 provide in-depth explanations and numerous examples of the major ADO.NET objects and the use of their properties and methods. Chapter 7 goes beyond the basics to explore advanced features and techniques of the ADO.NET objects.

    The third part of the book goes beyond the fundamental use of ADO.NET and shows how the technologies and techniques previously presented should be used to build real applications. This part includes the use of Visual Studio Data Projects for managing SQL scripts (Chapter 8), as well as a discussion of XML (Chapter 9) and the integration of XML and ADO.NET in Chapter 10. Finally, shown are additional types of projects that utilize ADO.NET—Chapter 11 covers ASP.NET Web Applications and Chapter 12 covers Web Services and middle-tier objects.

    The Software Environment

    We are assuming that the reader has already installed, or is capable of installing, Visual Studio .NET. The only thing to note regarding this is that there are significant differences between available capabilities and behaviors of the visual database tools, depending on the edition of Visual Studio and the type of database that you use.

    Parts of Chapters 1, 2 and 8 use features found only in the Enterprise Developer or Enterprise Architect versions of Visual Studio.

    Regarding the installation of SQL Server, Chapter 3 provides step-by-step instructions for installing SQL Server 2000, for those not familiar with the process. It is recommended that you make a copy or backup of the pubs sample database that is installed with SQL Server, since many of the code examples use this database and some of them modify the data that it contains.

    All of the Business Cases and many of the other code examples use the Novelty database, designed for this book. Both Chapters 3 and 8 show the development of SQL scripts to create this database. The following are the steps required to create the Novelty database on your SQL Server:

    In order to use many of the code samples in the book, you must first create and populate the "Novelty" database on a SQL Server 2000 machine. The steps provided here assume that the user you are logging in as has the rights necessary to create a database on the server. Keep in mind that some people may refer to a database and actually mean the application that handles the data—that is not the case on any page of this book. When the word database is used here, it explicitly means the container of organized, relational data kept in SQL Server 2000.



    Click below to download the Index file related to this title:


    Submit Errata

    More Information

    InformIT Promotional Mailings & Special Offers

    I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.


    Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

    This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

    Collection and Use of Information

    To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

    Questions and Inquiries

    For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

    Online Store

    For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.


    Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

    Contests and Drawings

    Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.


    If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

    Service Announcements

    On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

    Customer Service

    We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

    Other Collection and Use of Information

    Application and System Logs

    Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

    Web Analytics

    Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

    Cookies and Related Technologies

    This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

    Do Not Track

    This site currently does not respond to Do Not Track signals.


    Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.


    This site is not directed to children under the age of 13.


    Pearson may send or direct marketing communications to users, provided that

    • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
    • Such marketing is consistent with applicable law and Pearson's legal obligations.
    • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
    • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

    Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

    Correcting/Updating Personal Information

    If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.


    Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

    Sale of Personal Information

    Pearson does not rent or sell personal information in exchange for any payment of money.

    While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

    Supplemental Privacy Statement for California Residents

    California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

    Sharing and Disclosure

    Pearson may disclose personal information, as follows:

    • As required by law.
    • With the consent of the individual (or their parent, if the individual is a minor)
    • In response to a subpoena, court order or legal process, to the extent permitted or required by law
    • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
    • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
    • To investigate or address actual or suspected fraud or other illegal activities
    • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
    • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
    • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.


    This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

    Requests and Contact

    Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

    Changes to this Privacy Notice

    We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

    Last Update: November 17, 2020