O'Reilly logo

Programming Visual Basic 2005 by Jesse Liberty

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 2. Data Access

In Chapter 1, you created a couple of forms and some Find buttons, but your forms were left more or less inert; they do not interact with real data.

In this chapter you’ll begin to extract data from the Northwind database that comes both with SQL Server and SQL Server Express. You’ll use that data to fill in your forms. You’ll do this incrementally, adding complexity as you go. You’ll put a premium on using data controls provided with Visual Basic 2005 and letting the controls manage the “plumbing” of database interaction for you.

Tip

If you do not have either SQL Server or SQLServer Express you will need to download a copy from Microsoft. There is usually some form of demonstration version available, though the names and conditions change from time to time. As of this writing, SQL Server Express is bundled with all versions of Visual Studio 2005 or is available as a free download on the Microsoft site (http://www.Microsoft.com).

Adding Data to the Customer Page

Return to the first tab of frmCustomerDetails and give each text box a reasonable name (e.g. txtCustomerID, txtCity, and so on).

Tip

This chapter picks up on the code from the previous chapter. If you download the source, however, you’ll find that we’ve created folders with snapshots that represent the state of the code at the end of each chapter.

Create a Data Connection

You need a connection to the database. Before you begin, open the Data Sources Window (Data Show Data Sources). From this floating, dockable ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required