Microsoft Visual Basic 2005 Step by Step (Step by Step (Microsoft))
Chapter 18
Getting Started with ADO.NET
After completing this chapter, you will be able to:
Use the Data Source Configuration Wizard to establish a connection to a database and build a dataset.
Use the Dataset Designer and the Data Sources window to examine dataset members and create bound objects on forms.
Create datacentric applications using dataset and data navigator objects.
Use bound TextBox and MaskedTextBox controls to display database information on a Windows form.
Write SQL statements to filter and sort dataset information using the Visual Studio Query Builder tool.
In Part IV, you'll learn how to work with information stored in databases and Web sites. First, you'll learn about Microsoft ADO.NET, the newest paradigm for working with database information, and you'll learn how to display, modify, and search for database content by using a combination of program code and Windows Forms controls. Microsoft Visual Studio 2005 was specifically designed to create applications that provide access to a rich variety of data sources. These custom interfaces have traditionally been called database front ends, meaning that through your Visual Basic application, the user is given a more useful window into database information than simply manipulating raw database records. However, a more appropriate description in Visual Studio 2005 is that you can build datacentric applications, meaning that through your application, the user is invited to explore the full potential of any number of rich data source connections, whether to local or remote locations, and that the application places this data at the center of the user‘s computing experience.
In this chapter, you'll take your first steps with ADO.NET and with datacentric applications. You'll use the Data Source Configuration Wizard to establish a connection to an Access database on your system, you'll create a dataset that represents a subset of useful fields and records from a database table, and you'll use the Dataset Designer and Data Sources window to examine dataset members and create bound objects on your forms. You'll also learn how to use TextBox and MaskedTextBox controls to present database information to your user, and you'll learn to write SQL SELECT statements that filter datasets (and therefore what your user sees and uses) in interesting ways.
Upgrade Notes: Migrating Visual Basic 6 Code to Visual Basic 2005
The features in Visual Studio related to database programming have changed significantly in each recent release of the software. Although continually learning new techniques can be a source of frustration, the rapid pace of change can be explained partially by the relative newness of distributed and multiple-tier database application programming in Windows, as well as technical innovations that are beyond the control of the Visual Studio development team. If you're experienced with Microsoft Visual Basic .NET 2003, you'll notice several new windows and tools in Visual Studio 2005, although the underlying dataset model introduced with ADO.NET is still the same. (Microsoft ADO.NET 1.1 has been upgraded to Microsoft ADO.NET 2.0 with this release.) If you're experienced with Microsoft Visual Basic 6, you'll notice many new features in Microsoft Visual Basic 2005, including the following:
ADO.NET, first introduced in Microsoft Visual Studio .NET 2002, is the standard data model for all programs in Visual Studio 2005, including Microsoft Visual Basic, Microsoft Visual C++, Microsoft Visual J#, and Microsoft Visual C#. This version of ADO.NET offers a wider range of data access possibilities than its predecessors and is based on more recent Microsoft data access technology.
The Visual Basic 6 Remote Data Objects (RDO) and ActiveX Data Objects (ADO) data access models have been replaced by ADO.NET.
In Visual Basic 6, database information is represented in a program by the recordset object. In Visual Basic 2005, database information is represented by the dataset object, a disconnected image of the database table you're accessing.
The Visual Basic 6 Data and ADO Data controls are no longer available in Visual Studio 2005. To display data on a form, you typically create a dataset by using the Data Source Configuration Wizard and then add bound controls to your form to display information from the dataset. If you use the Data Sources window to do this, a navigation toolbar is added automatically.
The internal data format of ADO.NET is Extensible Markup Language (XML), making it easier to use existing XML data sources and to use ADO.NET in programs designed for the Web.