Visual Studio provides tools that make getting started with databases remarkably easy. Although the process is relatively straightforward, it does involve a lot of steps. The steps also allow several variations, so describing every possible way to build a database connection takes a long time. To make the process more manageable, the following two sections group the steps in two pieces: connecting to the data source and adding data controls to the form.

Connecting to the Data Source

To build a simple database program, start a new application and select the Data menu’s Add New Data Source command to display the Data Source Configuration Wizard shown in Figure 19-1.

FIGURE 19-1: Select the data source type for a new connection.


Visual Studio allows you to use databases, web services, and objects as data sources for your application. The most straightforward choice is Database. Select the type of data source you want to add (this example assumes it’s a database) and click Next to select a data model. The data model determines the kinds of objects your code can use to manipulate the data. This example assumes you will use a DataSet, which provides objects to represent tables and rows in the database. Pick the data model type and click Next to select a data connection on the page shown in Figure 19-2.

FIGURE 19-2: Pick the data connection or click ...

Get Visual Basic 2012 Programmer's Reference now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.