Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • sheetal 5 posts 75 karma points
    Dec 17, 2018 @ 11:27
    sheetal
    0

    Umbraco Connection String

    Hi , for some reason I need to change my connection string dynamically from code. I do not want to put the connection value in config file. Suggest me if there is any other solution except config file.

  • Dan Diplo 1505 posts 5911 karma points MVP 4x c-trib
    Dec 17, 2018 @ 12:49
    Dan Diplo
    0

    I've never tried it, but in theory you can use:

    ApplicationContext.Current.DatabaseContext.ConfigureDatabaseConnection(connString) 
    

    to set the database connection.

    I'd imagine you'd need to do this in the Application Startup events (not sure which one - but as early as possible, I'd guess). See below:

    https://our.umbraco.com/Documentation/Reference/Events/Application-Startup

    Again, not sure if it will work, but seems your best bet.

  • sheetal 5 posts 75 karma points
    Dec 17, 2018 @ 12:51
    sheetal
    0

    Thanks Dan, for the reply.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies