Monday 27 May 2013

Create Data Connection Library


Prerequisites: the Data connection Library is only available for the Enterprise Version of SharePoint

First go to site setting -> Manage Site Feature

Next activate the SharePoint Server Enterprise Site Features
and now when you go to create a new document library, the Data Connection Library is available.

so lets go ahead and create our library.
Our list Library url should be: http://yoursite:portnumber/Data Connections/

now all that being said you could instead activate it using a feature receiver like so

// Uncomment the method below to handle the event raised after a feature has been activated.
public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
    using (SPWeb web = properties.Feature.Parent as SPWeb)
    {
        //SharePoint Server Enterprise Site features guid
        Guid spServerEnterpriseSiteFeatures = new Guid("0806d127-06e6-447a-980e-2e90b03101b8");
 
        if (web.Features[spServerEnterpriseSiteFeatures] == null)
        {
            web.AllowUnsafeUpdates = true;
            web.Features.Add(spServerEnterpriseSiteFeatures, true);
            web.AllowUnsafeUpdates = false;
        }
 
        CreateList(web, "Data Connections"SPListTemplateType.DataConnectionLibrary);
    }
}
 
private void CreateList(SPWeb web, string listName, SPListTemplateType listType)
{
    string description = string.Format("{0} created programatically", listType.ToString());
 
    if (web.Lists.TryGetList(listName) == null)
    {
        web.AllowUnsafeUpdates = true;
        web.Lists.Add(listName, description, listType);
        web.AllowUnsafeUpdates = false;
    }
}