Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>UPDATE</strong></p> <p>Whew, 2009 sure was a long time ago ;) I'm going to leave the original answer for posterity, but, as <a href="https://stackoverflow.com/a/1343397/130480">Eric J. already stated in an updated version of his post in 2012</a>, <a href="https://www.nuget.org/packages/SlowCheetah/" rel="nofollow noreferrer">Slowcheetah</a> is a much more flexible approach to this problem as it let's you create multiple config file per configuration. </p> <p><strong>Original answer</strong></p> <p>I can't answer for the publish part as I'm not sure it can be done. However, for the connection string part, you could make a "Connection String Provider Class" which would return the development connection string if you are in development, or the production connection string if you are in production.</p> <p>I don't know if you are using Debug and Release compilation mode in the configuration manager, but it could be possible to use that with a pre-compiler directive:</p> <pre><code>public class ConnectionStringProvider { public static string GetConnectionString() { #if (DEBUG) return DevConnectionString; #else return ProdConnectionString; #endif } } </code></pre> <p>If you are using the VS2005 Settings pane (in the project settings), you can set 2 connections strings in there and use that instead of a constant value. If you are using any of the .Net DataSource, you could be always using the DEV connection string to create your object.</p> <p>Also, the connection string provider could use a Singleton pattern, but I'm not sure there would be a real benefit.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload