how read web.config from timer jobs

Posted by Sagarp under SharePoint on 2/25/2010 | Views : 6429 | Status : [Member] | Replies : 3
Hi

how to read the connection string from the Web.config of the Web Application in timer jobs?

Thanks
SagarP
http://www.emanonsolutions.net
http://emanonsolutions.blogspot.com/



Responses

Posted by: Abhi2434 on: 2/25/2010 [Member] [Microsoft_MVP] [MVP] Silver

Up
0
Down
I never used Sharepoint.
Doesnt it support ConfigurationManager.ConnectionString ?

I hope this would work from WebParts as well.

www.abhisheksur.com

Sagarp, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Nishithraj on: 2/25/2010 [Member] Bronze

Up
0
Down
Try with following code

SPWebApplication webApplication = this.Parent as SPWebApplication;

Configuration config = WebConfigurationManager.OpenWebConfiguration("/", webApplication.Name);
String appValue = config.AppSettings.Settings["ConnStr"].Value;


Mark this as answer, if it is.....

With regards
Nishithraj Narayanan

Sagarp, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Praveenbattula on: 4/6/2010 [Member] Starter

Up
0
Down
Here is the complete solution of what you are looking for.
http://praveenbattula.blogspot.com/2009/12/access-webconfig-in-sharepoint-timer.html

Rare Solutions.
http://praveenbattula.blogspot.com

Sagarp, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response