SPDataStore.CreateDataSource method

Saves a data source object as a content type in a SharePoint document library.

Namespace:  Microsoft.PerformancePoint.Scorecards.Store
Assembly:  Microsoft.PerformancePoint.Scorecards.Store (in Microsoft.PerformancePoint.Scorecards.Store.dll)

public DataSource CreateDataSource(
	string listUrl,
	DataSource dataSource


Type: System.String

The server-relative URL of the SharePoint document library to save the data source to. Example: /BI Center/Data Connections for PerformancePoint.

Type: Microsoft.PerformancePoint.Scorecards.DataSource

The data source object to save, which specifies values for the required Name property. For custom data sources, dataSource must also specify the SubTypeId property, and the value must match the subType attribute specified for the custom data source in the web.file for PerformancePoint Services in SharePoint Server 2013.

Return value

Type: Microsoft.PerformancePoint.Scorecards.DataSource
The new object, which contains updated information such its location and version number.


IBIMonitoringStore.CreateDataSource(String, DataSource)

For PerformancePoint Services development, use the BIMonitoringServiceApplicationProxy.CreateDataSource(String, DataSource) method instead of using this implementation. For more information, see the "Interacting with Repository Objects" section in Editors for Custom Objects.

The following code example shows how to use a private method to create a data source and call BIMonitoringServiceApplicationProxy.CreateDataSource(String, DataSource) to save it to the repository.

Before you can compile this code example, you must do the following:

  • Configure your development environment and create a C# class library project in Visual Studio. For information about configuring a development environment, see Set up a general development environment for SharePoint 2013.

  • Add the Microsoft.PerformancePoint.Scorecards.Client, Microsoft.PerformancePoint.Scorecards.ServerCommon, and Microsoft.SharePoint DLLs as references to your project. For more information about PerformancePoint Services DLLs, see PerformancePoint Services DLLs Used in Development Scenarios.

  • Add the following using directive to your class: using Microsoft.PerformancePoint.Scorecards;.

// Create a data source that uses the Adventure Works sample cube, based on the following parameters:
//   - dataSourceName is the name for the data source.
//   - docLibUrl is the server-relative URL of the document library to save the data  
//         source to. Example: "/BI Center/Data Connections for PerformancePoint"
// This method returns the new data source. 
private DataSource CreateDataSource(string dataSourceName, string docLibUrl)
    if (String.IsNullOrEmpty(dataSourceName))
        throw new ArgumentException("The name must not be null or empty.");
    if (String.IsNullOrEmpty(docLibUrl))
        throw new ArgumentException("The document library URL must not be null or empty.");

    // Create an ADOMD.NET data source that represents the Adventure Works sample cube.
    DataSource ds = DataSource.CreateNew();
    ds.Name.Text = dataSourceName;
    ds.Description.Text = "Created with the SDK.";
    ds.ServerName = "MyServer";
    ds.DatabaseName = "Adventure Works DW";
    ds.CubeName = "Direct Sales";

    // The SourceName property must match the name of a data source provider registered in
    // the CustomDataSourceProviders section of the PerformancePoint Services web.config file.
    // The default path to the web.config file is 
    // %ProgramFiles%\Microsoft Office Servers\14.0\WebServices\PpsMonitoringServer.

    ds.SourceName = "ADOMD.NET";

    // Call the CreateDataSource method to save the new data source to the specified document library.
    // TODO: Handle exceptions from this call.
    // All interaction with the data source should go through the application server.
    // If this code is running within the application server, call the data store directly, as follows.
    // return SPDataStore.GlobalDataStore.CreateDataSource(docLibUrl, ds);

    // If this code is running on a front-end Web server, call the service application proxy, as follows.
    return BIMonitoringServiceApplicationProxy.Default.CreateDataSource(docLibUrl, ds);