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 1554 posts 6205 karma points MVP 5x 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.

Please Sign in or register to post replies

Write your reply to:

Draft