none
Connection string RRS feed

  • Question

  • Hi Guys,

     

    I've made one project but I want to provide the functionality to modify the connectionstring from a file. Unfortunately I have used table adapters as well in my project and therefore though I'm getting the server name and connection string from an inf file, its still not working when I click on form which have grid.

    Is there any way of writing to settings file or have my connection read into config file.

     

    TA
    Gemma

    Tuesday, October 2, 2007 4:38 PM

Answers

  • Hi Gemma,

     

    Check your applications config file (app.config) I believe that once you configure table adapters the connection string is stored in the file under the <connectionStrings> element. Changing this connection string should update all table adapters that reference it (each connection string should have a name attribute and it's this name attribute that is used by the table adapters, so it's the only thing you shouldn't change)

     

    Monday, October 8, 2007 5:06 PM

All replies

  • Write the following code in app.config

    <appSettings>
      <add key="ConnectionString" value="server=servername; database=sample; user=sa; password=sa; Min Pool Size=1; Max Pool Size=1000; Connection Lifetime=80"/>
      
     </appSettings>

     

    Retrieve the connection using following sentence

     

        public static string sConString = System.Configuration.ConfigurationManager.AppSettings["ConnectionString"];

    Friday, October 5, 2007 10:11 AM
  • Hi Gemma,

     

    Check your applications config file (app.config) I believe that once you configure table adapters the connection string is stored in the file under the <connectionStrings> element. Changing this connection string should update all table adapters that reference it (each connection string should have a name attribute and it's this name attribute that is used by the table adapters, so it's the only thing you shouldn't change)

     

    Monday, October 8, 2007 5:06 PM