Connection strings in separate file

2 posts, 1 answers
  1. Andrew
    Andrew avatar
    70 posts
    Member since:
    Oct 2008

    Posted 19 Oct 2009 Link to this post

    Hi,

    This is a "small" issue, but worth while dealing with.

    One problem with development and then later deployment to a test system and finally to production, is that the database connection strings will (may) be different in each case.

    In my projects, I have got into the habit of using a separate file to hold connection strings, and refer to that file using the "configSource" directive.

    So for example in my web.config instead of a <conenctionStrings section with all the strings embdeded I simply code the following:
      <connectionStrings configSource="connection.config" /> 
     
    Then I create a separate file called connection.config which holds the actual connection data.
    <connectionStrings> 
      <remove name="LocalSqlServer" /> 
      <add name="XXXConnection" connectionString="Data Source=SERVERNAME;Initial Catalog=DATABASENAME;Integrated Security=True" providerName="System.Data.SqlClient" /> 
    </connectionStrings> 
     
    Then when I deploy to different environments, I don't deploy the "development" conneciiton.config file instead the file of that name in each environment already has the correct values for that environment.

    I use the same "trick" with OA, in the section <openaccess>, I replace the <connections> ..... </connections> with:

        <connections configSource="connectionOA.config" /> 
     
     and put my actual connection data into the file "connectionOA.config" as follows:
    <openaccess xmlns="http://www.telerik.com/OpenAccess">  
      <connections configSource="connectionOA.config">  
        <connection id="MADConnection">  
          <databasename>MAD_Live</databasename> 
          <servername>Andy-i7-PC\ENTERPRISE2008</servername> 
          <integratedSecurity>True</integratedSecurity> 
          <backendconfigurationname>mssqlMADConfiguration</backendconfigurationname> 
        </connection> 
      </connections> 
    </openaccess> 
     
    am not sure why I have to repeat the <openaccess ...> tags, whether they are there or not it all works, but visual studio does compain without them.

    FIrstly it would be nice if you could arrange that the connection data was the same as for the rest of the project (i.e. connectionStrings her than connections). That way I only need the one file of connection info.

    Secondly, if I run the Open Access -> Configuration -> Check Settings it complains saying

    Validator :

     

    <connections> section

     

    Description :

     

    'Connections' node not present in config file.

     


    Which is of course not true since there is a <connections> section - it is just not as the checker expects. So it woudl be nice if this were to run cleanly (not a major issue, but tidyness is a good thing).
  2. Answer
    Dimitar Kapitanov
    Admin
    Dimitar Kapitanov avatar
    632 posts

    Posted 22 Oct 2009 Link to this post

    Hello Andrew,
    We will be introducing a way to handle the native ado.net connection strings in the natural for .net way with Telerik OpenAccess ORM, starting with Q3. I am not that all 100% functionality will be there (in terms of UI and validations) but you will be able to work the way you think it is natural with connection strings, including 'in-code' API will be available.

    Sincerely yours,
    Dimitar Kapitanov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. DevCraft banner
Back to Top