Share via


Data Search Sample

This sample demonstrates how to display a subset of data from your database.

To get samples and instructions for installing them

  • Do one or more of the following:

    • On the Help menu, click Samples.

      The Readme displays information about samples.

    • Visit the Visual Studio 2008 Samples Web site. The most recent versions of samples are available there.

    • Locate samples on the computer on which Visual Studio is installed. By default, samples and a Readme file are installed in drive:\Program Files\Microsoft Visual Studio 9.0\Samples\lcid. For Express editions of Visual Studio, all samples are located online.

For more information, see Visual Studio Samples.

Security noteSecurity Note:

This sample code is intended to illustrate a concept, and it shows only the code that is relevant to that concept. It may not meet the security requirements for a specific environment, and it should not be used exactly as shown. We recommend that you add security and error-handling code to make your projects more secure and robust. Microsoft provides this sample code "AS IS" with no warranties.

To run this sample

  • Press F5.

Requirements

This sample requires the Northwind sample database. For more information, see How to: Install and Troubleshoot Database Components for Samples.

Demonstrates

Most of this form was created using the designer tools in Visual Basic. The following is a summary of how you could create this form from scratch.

To create this sample

  1. Create a new Windows Application project.

  2. Using the Data Source Configuration Wizard, create a connection to the Northwind database, selecting the Customers table, and saving the connection string in the application configuration file.

  3. Open the Data Sources Window and drag the Customers table onto the form. DataGridView and BindingNavigator controls are added to the form and configured for the Customers table.

  4. On the smart tag for the DataGridView, click Add Query. In the dialog box, change the New Query Name to FillByLastName. In the Query Text, add WHERE LastName LIKE @lastName + '%' to the end of the Select statement. A ToolStrip control for searching is added to the form.

  5. Double-click NorthwindDataSet in Solution Explorer. This opens the code file NorthwindDataSet.xsd. Notice the FillByLastName method is added to the CustomersTableAdapter.

See Also

Tasks

How to: Install and Troubleshoot Database Components for Samples

Concepts

What's New in Data

TableAdapter Overview