Scenario:
I wrote a timer job and basically in this timer job I wanted to update the DB depending upon sharepoint information. That means i need to have a connection string to make the connection ( mostly in some config file ). This timer job was attached to a Web Application , so I decided to read the connection string from the Web.config of the Web Application
Solution:
WebConfigurationManager class exposes a method OpenWebConfiguration to make it easier to read.
Code:
Configuration config = WebConfigurationManager.OpenWebConfiguration("/", this.WebApplication.Name);Article:
string _sqlConnectionString = config.ConnectionStrings.ConnectionStrings["DBConnectionString"].ToString();
Points To Share
1 comments:
Thanks..this is really useful
Post a Comment