1

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>
      </data>

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>
          </data>
3
  • 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
2

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

1
  • 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
1

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.
0

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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