Tech Off Thread

11 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

Best Practice for changing Connection String in multiple builds

Back to Forum: Tech Off
  • User profile image
    DJZ

    Playing around with the VS205 IDE, some of the new tools are pretty nice.

    What I can't figure out how to do, is to have multiple build configurations, debug, relese, test etc, each with its own connection string, and configure and build this through the IDE.

    Requirements:
    At build time, use the GUI to set the connection string for each environment, and use it for the TableAdapter.
    Build a configuration, targetted at one of these environments.

    Is this possible?
    If not, what is the best way to do this?

    I can use NAnt to specify the settings file for the particular build, however I really want to see what this IDE can do.

  • User profile image
    DJZ

    200+ views, no replies, is that a record?

    Bad question, poorly worded, no solution?

    My first new thread, you'll give me a complex!

  • User profile image
    SlackmasterK

    oh I dunno; let's do some math.  Look at current techoff ratios:

    Replies / Views:
    1 / 234
    1 / 120
    12 / 1395
    7 / 2040

    Sandbox:
    6 / 3486
    3 / 1186

    Coffeehouse:
    46 / 15546
    174 / 12248

    Clearly the ratio depends on the forum.

  • User profile image
    amotif

    Have you considered making your connection string a deploy-time configuration item rather than a build-time issue? Most of the systems I've worked on consider a deployment issue.

  • User profile image
    ben2004uk

    I have been having this discussion with people recently.  Some people want build time, and some want it to be changed manually depending on what it is doing.....

    So out of interest, how do you do Deploy time configuration??

  • User profile image
    blowdart

    ben2004uk wrote:

    I have been having this discussion with people recently.  Some people want build time, and some want it to be changed manually depending on what it is doing.....

    So out of interest, how do you do Deploy time configuration??



    Config file. Hard coding a connection string into a Table Adapter just feels so very very wrong Smiley

    Why can't the table adapter read the string from app.config?

    (And of course what you could do in the build is have a directory in your project containing multiple config files, release, debug, whatever and post build copy the one you want into the deployment directory, or the directory you build your MSI fom

  • User profile image
    DJZ

    blowdart wrote:

    Why can't the table adapter read the string from app.config?


    That's pretty much what I want to do.

    I wouldn't hard code in the Table Adapter.  The TA should look for a parameter in the relevant config file for that environment.

    I could have multiple config files as you suggest, what I was looking for was a way to include the correct config file into the build for the particular environment.

    Really just saves the last deployment step of copying/moving/renaming config files.





  • User profile image
    JohnAskew

    http://msdn.microsoft.com/practices/Topics/security/default.aspx?pull=/library/en-us/dnpag2/html/pagguidelines0002.asp

    This is a patterns & practices link for security and ADO.NET

    It has good ideas to look into for connection strings too.

  • User profile image
    ScaleOven​Stove

    have your current app.conifg or web.config, and then override the connection string with another config file using the file="DynamicSettings.config" or something. Then on each build that file would be the only thing different. You woudnt merge up the dynamic settings at all to your release build.

  • User profile image
    Harlequin

    Just make your own config file, we have a database.config and each special connection has 2 nodes:
    <Development>local database connection</Development>
    <Live>live database connection</Live>

    If the IP is the IP of the development server, use the Development string
    else
    use the other

  • User profile image
    phreaks

    If your environments are all seperate machines, utilize the machine.config file.

    Then you never have to change any code when moving between environments.
      Expressionless

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.