Share via


How to: Connect to Data in an Object

You can connect your application to data in objects by running the Data Source Configuration Wizard and selecting Object as the data source type.

After completing the wizard, a data source based on the selected object is added to your project and is immediately available in the Data Sources Window. You can drag items from the Data Sources window onto a form in your Windows application to create controls that are data-bound to the selected properties of your object. For more information, see Displaying Data Overview.

Note

The dialog boxes and menu commands you see might differ from those described in Help depending on your active settings or edition. To change your settings, choose Import and Export Settings on the Tools menu. For more information, see Visual Studio Settings.

Creating an Object Data Source

To create a new data source from an object

  1. On the Data menu, click Add New Data Source.

  2. Select Object on the Choose a Data Source Type page.

  3. On the Select an Object you wish to bind to page, select an object already in your application.

    Note

    You may need to build the project that contains your object before the object appears in the wizard.

    -or-

    Add a reference to an object not currently in your application by clicking Add Reference and locating the desired assembly in the Add Reference Dialog Box. The assembly is added to the tree view.

  4. Expand the assembly that contains the object you want to bind to and select the object in the tree view.

  5. Click Finish.

    The data source is added to the Data Sources window.

Creating Controls That Are Bound to Your Object

To add functionality to your application

  1. Choose Show Data Sources on the Data menu to display the Data Sources window.

  2. Select an item in the Data Sources window and drag it onto a form to create a control that is bound to the properties in your object. Repeat this step as necessary for other items as needed.

    For more information, see Displaying Data Overview.

See Also

Tasks

Walkthrough: Connecting to Data in Objects

Other Resources

Displaying Data on Forms in Windows Applications

Getting Started with Data Access

Connecting to Data in Visual Studio

Preparing Your Application to Receive Data

Fetching Data into Your Application

Displaying Data on Forms in Windows Applications

Editing Data in Your Application

Validating Data

Saving Data

Data Resources