Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
We're trying to have Umbraco use a connection string we pass it from the code. Reason being, we get the connection string from outside of the web.config and we can't change this constraint.
Is it possible to do this? We are not allowed to modify the web.config from the source code as well so editing it from the code to add the UmbracoDbDSN parameter is not an option...
Welcome to our community,
Try to look at this code :
Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
config.AppSettings.Settings["umbracoDbDSN"].Value = “New Connection String”;
thanks a lot for your help.
We've tried and used this successfuly but we are unfortunately not allowed to modified the web.config file anymore...so this solution couldn't work for us.
Looks like here is solution of your problem - https://our.umbraco.org/forum/developers/api-questions/56150-Connection-string-in-code
Spent some time testing this solution as well but whichever way I try to access the configuration it is read only (ApplicationContext.DatabaseContext.Database.Connection.ConnectionString is readonly)
What I was hoping for was a way to hook up in the Umbraco database layer initialization and being able to "inject" a different connection string. But looking at the Umbraco source code, it doesn't seem to be feasable...any suggestion would be appreciated.
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted