Export (0) Print
Expand All

Data Sources Overview

Data sources represent the data available to your application. More specifically, data sources represent the data that you want to work with in your application. Data sources can be obtained from databases (including local database files), services, and objects.

The data sources that you add to your project are displayed in the Data Sources window. In many cases, you can drag data sources to the Windows Forms, WPF, and Silverlight designers to create controls that are bound to the underlying data. For more information, see Binding Controls to Data in Visual Studio.

Visual Studio provides tools for creating and editing data sources in your application. Data sources in Visual Studio projects are represented as Entity Data Models, datasets, proxy objects returned by a service, or other object types, depending on the objects that are returned by the underlying data store.

You create and edit data sources by using the Data Source Configuration Wizard.

You can create a data source from a database by running the Data Source Configuration Wizard and selecting the Database data source type. For more information, see How to: Connect to Data in a Database.

When you create a data source from a database, Visual Studio generates a data model and adds it to your project. A data model is a strongly typed, programmable view of the underlying data in the database. You can use Visual Studio to create the following types of data models:

You can also create data sources from the following types of database files: Access databases (.mdb files), SQL Server Express LocalDB databases (.mdf files), and SQL Server Express databases (.mdf files). When you create data sources from these database files, you can add the database files directly to your project. For more information, see the following topics:

You can create a data source from a service by running the Data Source Configuration Wizard and selecting the Service data source type. For more information, see How to: Connect to Data in a Service.

When you create a data source from a service, Visual Studio adds a service reference to your project. Visual Studio also creates proxy objects that correspond to the objects that are returned by the service. For example, a service that returns a dataset is represented in your project as a dataset; a service that returns a specific type is represented in your project as the type returned.

You can create a data source from the following types of services:

  • WCF Data Services. For more information, see WCF Data Services Overview.

  • Windows Communication Foundation (WCF) services. For more information, see Windows Communication Foundation Services and WCF Data Services in Visual Studio.

  • Web services. For more information, see Introduction to Programming Web Services in Managed Code.

    Note Note

    The items that appear in the Data Sources window are dependent on the data that is returned by the service. Some services might not provide enough information for the Data Source Configuration Wizard to create bindable objects. For example, if the service returns an untyped dataset, no items will appear in the Data Sources window upon completing the wizard. This is because untyped datasets do not provide a schema, and therefore the wizard does not have enough information to create the data source.

You can create a data source from any object that exposes one or more public properties by running the Data Source Configuration Wizard and then selecting the Object data source type. All public properties of an object are displayed in the Data Sources window. For more information, see How to: Connect to Data in Objects.

For more information about binding to objects, see Object Binding in Visual Studio.

You can create a data source from a SharePoint list by running the Data Source Configuration Wizard and selecting the SharePoint data source type. SharePoint exposes data through WCF Data Services so creating a SharePoint data source is the same as creating a data source from a service. Selecting the SharePoint item in the Data Source Configuration Wizard opens the Add Service Reference dialog box where you connect to the SharePoint data service by pointing to the SharePoint server. For more information, see How to: Connect to Data in a Service.

Show:
© 2014 Microsoft