How to: Scroll through database records in a worksheet

Applies to: yesVisual Studio noVisual Studio for Mac

Note

This article applies to Visual Studio 2017. If you're looking for the latest Visual Studio documentation, see Visual Studio documentation. We recommend upgrading to the latest version of Visual Studio. Download it here

The following procedure shows how to use the designer to display a single field from a database table in a Microsoft Office Excel worksheet, with controls that enable the end user to scroll through all the records.

You can use the designer only in document-level projects. However, you can also add controls and bind them to data programmatically at run time. For more information, see Walkthrough: Simple data binding in VSTO Add-in project.

Applies to: The information in this topic applies to document-level projects for Excel. For more information, see Features available by Office application and project type.

To scroll through database records in a worksheet

  1. Open an Excel application project in Visual Studio.

  2. Open the Data Sources window and create a data source from the database. For more information, see Add new connections.

  3. Expand the table that contains the data that you want to show, and select the specific column.

  4. Open the list of controls and select NamedRange.

  5. Drag the NamedRange control onto the cell where you want the data to appear.

  6. From the Windows Forms tab of the Toolbox, add a BindingNavigator control to your worksheet, and set up the controls you want to use. For more information, see BindingNavigator control overview (Windows Forms).

See also