changing connection string without resetting iis

Locked changing connection string without resetting iis

  • 6 марта 2012 г. 18:51
     
     

    Hey

    I have a websit running where I have a dbHandler with a connection string stored in a xml file, when I change it to another database it dose not work before I have reset IIS, how can I change that ?

Все ответы

  • 10 марта 2012 г. 18:54
     
     

    Hi,

    did you get any Error message ?

    Kayden

  • 11 марта 2012 г. 6:42
     
     

    Hey

    No but what I did was, trying to change to an other sql server, but it still connects to the first.

    Bendix

  • 11 марта 2012 г. 11:27
     
     Предложенный ответ С кодом

    Dear friend,

    you can do it without reset IIS.

    Any change in Web.config file will cause ASP.NET application to restart. But, it is possible to create one or more external .config files which don't cause application restart. To connect external .config files with main Web.config, use configSource parameter. Here is an example code snippet, used to read external configuration from three files:


    <connectionStrings configSource="db.config"/>
           <appSettings configSource="app.config"/>
       
           <system.net>
               <mailSettings>
                   <smtp configSource="mail.config"/>
               </mailSettings>
           </system.net>

    So, in this example, we can change connection strings, application settings and mail settings. Application will not restart when any of these files change. Any external .config file should contain only section where is called. For example, db.config is called from <connectionStrings /> and should contain only connection strings, like this:


    <connectionStrings>
         <clear />
         <add name="ConnStringName" connectionString="Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated Security=SSPI;" providerName="Syste.Data.SqlClient"/>
       </connectionStrings>

    this link will support you to do this.

    change website configuration without restarting ASP.NET


    ESLAM ELMOAWEN Software Developer

    • Предложено в качестве ответа ESLAM ELMOAWEN 11 марта 2012 г. 11:34
    •  
  • 1 мая 2012 г. 7:26
     
     

    Thanks that wase a big help

    Now I am trying to change the connection string while the site is running, I found this by google

    but I get this error

    "exePath must be specified when not running inside a stand alone exe"

  • 1 октября 2012 г. 23:30
     
     

    Dear Sir,

    i hope this link support you in your old issue.

    exePath must be specified when not running inside a stand alone exe


    ESLAM ELMOAWEN Software Developer


    • Изменено ESLAM ELMOAWEN 1 октября 2012 г. 23:32 insert link
    •