Config API, adding new connection string

Posted by Community Admin on 04-Aug-2018 22:07

Config API, adding new connection string

All Replies

Posted by Community Admin on 23-Feb-2013 00:00

Hi,

I tried to add new connection string using API. So far I've for the following:

var conStrings = Config.Get<DataConfig>().ConnectionStrings;
if (!conStrings.ContainsKey("Sitefinity4"))
    Config.UpdateSection<DataConfig>(config =>
        config.ConnectionStrings.Add(new ConnStringSettings(<?????>, "Sitefinity4", "data source=localhost;Integrated Security=SSPI;initial catalog=db_name")));

Is Config.UpdateSection<DataConfig> right function to update DataConfig file? And what should I pass instead <??????>. Thanks, Denis.

This thread is closed