SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using a resource file to store the database connection string. This was successfully deployed in {SharePointRoot}\Resources\. I tried editing the file and change some of the values just to test it but it's not getting the current value on the XML file instead it's still using the old value. I searched for any resource file in case it was saved somewhere else but I found none. Why is my web part still using the old connection string? I refreshed the page several times.

Old value:

 <data name="HBConnectionString" xml:space="preserve">
        <value>Data Source=DevServer;Initial Catalog=db;user=user;password=pwd;Pooling=false;</value>
        <comment>HelpBox connection string</comment>

new value:

 <data name="HBConnectionString" xml:space="preserve">
            <value>Data Source=TestServer;Initial Catalog=db;user=user;password=pwd;Pooling=false;</value>
            <comment>HelpBox connection string</comment>
share|improve this question
Do you use SP2010 or SP2007? Are you deploying from Visual Studio? – Andrey Markeev May 26 '11 at 7:57
you really shouldnt use resource files for this. Check my answer below... – Anders Rask May 26 '11 at 9:10
I am using SP2010 and deploying on VS2010. – SPNotSoNewbieNow May 29 '11 at 18:30
up vote 2 down vote accepted

You should not store database connection strings in Resource files.

SharePoint 2010 has a new feature that can be used for this. It is called Secure Store Service.

Read this guide MSDN to get it working

share|improve this answer
How do you use Secure Store Service if you are you are passing the connection string to connect to a datacontext? This is basically the reason why I'm using the resource file for this because I don't know how to access the credentials I saved on the Secure Store Service. I only know how to use it when creating external content types but not with datacontext. I am creating a web part that accesses an external database, what will be the best approach for this without hard coding the connection string? thanks! – SPNotSoNewbieNow May 29 '11 at 18:13

Depending on where you store your resources you need a different approach:

  • {SharePointRoot}\config\resources - These are copied to the wwwroot by issuing the following command: stsadm -o copyappbincontent
  • {SharePointRoot}\resources (your situation) - Requires an iisreset as these files are cached.
share|improve this answer

You might need to do an IISReset between making changes to SharePointRoot

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.