How to Access Data from a SharePoint List Based on a Custom View



The CData ADO.NET Providers for SharePoint you to integrate live SharePoint data with other applications. For example, Visual Studio provides built-in support for ADO.NET data sources. This article shows how to use Server Explorer in Visual Studio to access the data screened by a SharePoint custom view.

Implementing Access Control with a Database Query

The CData ADO.NET provider's data model exposes each SharePoint list as a separate table; all custom views are available by querying the Views table. You can implement the settings for the custom view that you defined in SharePoint by selecting data with the ID of the custom view:

  1. If you have not already done so, establish a connection to SharePoint: In Server Explorer, right-click the Data Sources node and click Add Connection.

    See the "Getting Started" guide chapter in the help documentation for a guide to the required connection properties and how to set them in Server Explorer.

  2. Retrieve the unique identifier for the custom view: Query the Views table and specify the custom list for the view. For example, the query below retrieves all custom views for the custom list MyCustomList:
    SELECT * FROM Views WHERE List='MyCustomList'
  3. Query the custom list table to retrieve the custom view. Specify the ViewId in the WHERE clause. For example, to retrieve a custom view from MyCustomList, use the following statement:
    SELECT * FROM MyCustomList WHERE ViewId='your-ViewId'