Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have a timer job that needs to connect to a SQL Database.

Where would one typically store this connection string.

In normal app development, one has app.config. Clearly using app.config in this scenario is not the right place for the configuration to be stored.

Ideally I'm looking for a way the user can change the connection string.

Do I need to create a custom list, or is there a proper way to store configuration such as this connection string?

share|improve this question

2 Answers 2

up vote 1 down vote accepted

I have posted a viable option and few pointers here.

share|improve this answer

you could use a list, or another way is to use SPWebConfigModification to store the string you need into the appsettings node of web.config on feature activation, and just use the AppSettings property bag to access it.

The benefit of SPWebConfigModifications are that the the changes are affected to multiple web-front ends if you have many, otherwise you can make a static change to the web.config directly if you're in dev, or only have one web frontend.

share|improve this answer
    
Problem I have with SPWebConfigModification, is it would theoretically cause the web application in IIS to restart if it is modified. Are you 100% sure there isn't a built in way to manage configuration for timer jobs natively in SP2010? –  user879 Dec 8 '10 at 8:50
    
Could have a look at SPPersistedObject - create a class which represents the configuration for your timerjob and inherit from SPPersistedObject. –  James Love Dec 8 '10 at 9:08
    
I discovered that the SPJobDefinition has a properties collection. This can be set during feature activation where you define the job. But I'm trying to find out how to expose this to a sharepoint admin via central admin. –  user879 Dec 8 '10 at 9:19

Your Answer

 
discard

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.