My Technical Notes

Thursday, 14 March 2013

Storing Connection Strings in Sharepoint 2010

One can store connection strings in plenty of ways in Sharepoint 2010, but one way I have settled on is to store it in the Site or Site Collection's property bag. To access the Site's properties, Open SharePoint Designer and then click on Site Options in the Ribbon:

Picture of Site Options Icon in the Ribbon Toolbar

Thereafter, click on the Add... button and then you can add a Parameter, which consists of a name and a value:

To access the value from a Web Part we can use the Web's AllProperties to access the value:


SPContext.Current.Web.AllProperties["my_parameter_name"];

The people who can access this parameter are people with Full Control and/or Design permissions.

No comments: