+1-888-365-2779
Try Now
More in this section

Forums / Deployment / Different connection strings on Debug / Release

Different connection strings on Debug / Release

6 posts, 0 answered
  1. ManniAT
    ManniAT avatar
    9 posts
    Registered:
    08 Nov 2003
    18 Dec 2010
    Link to this post
    Hi,

    I'm just working on a blog about SF deployment to a / my shared hosting provider.
    I'm using RC 4 by the way.


    Startup - create a SQL Server DB and use it with my SF project.
    -- here I use (if possible) similar settings as I will use with the provider.

    Next I create instant content and transfer the DB to my provider.
    Then (using Visual Studio) I build and deploy my project.

    As soon as my site is the first time deployed (including Database) I should / must always use the
    Database hosted by my provider.

    I can't use the same connection string from my development machine and my provider.
    Once I use
    "Data Source=external.server.addre.ss;Initial Catalog=SFManniAT;Integrated Security=False;Persist Security Info=True;User ID=MyExternalUser;Password=ExternalPWD;Network Library=dbmssocn"
    And with the provider I use
    a.) a different Network library
    b.) a different server name (Data Source)
    c.) a different user (maybe)
    d.) a different pwd (maybe)

    With normal Visual Studio Projects I'm used to handle these things in Package/Publish SQL.
    So I have one connection string for "in house build" and another one for "deployment build".

    I have no problem with editing DataConfig.config - but I'm curious if there is a simple way to automate this task.
    -- Doing this by hand is "dangerous" - if I forget it my site is broken.

    In simple words is there a way to provide a different DataConfig.config depending on the build configuration?

    Thank you
    Manfred
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    30 Sep 2016
    20 Dec 2010
    Link to this post
    Hi ManniAT,

    You can create a second connection string inside Sitefinity/Administration/Settings/Advanced Data >> Connection strings. When you move the database to another server you can just switch the connection strin from the UI.

    You cannot have more than one DataConfig file. The DataConfig is used by StartupWizard and OpenAccessDecorator which expects a certain configuration type - Telerik.Sitefinity.Data.Configuration.DataConfig

    Regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. ManniAT
    ManniAT avatar
    9 posts
    Registered:
    08 Nov 2003
    20 Dec 2010
    Link to this post
    OK,

    I could set another connection string in Admin....
    Now I've two connection strings in DataConfig.config.

    But how do I switch them?
    There is no "use this" checkmark in the config section.

    And a simple test (renaming the Sitefinity connection string) shows that this value is "hardcoded" somewhere.
    When I change (via Admin..) the name and restart the application I get an error message that "Sitefinity" connection was not found.

    Last not least we are maybe talking about different solution approaches - but let's first fix this.

    So please tell me where I can choose the used connection string.

    Manfred
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    30 Sep 2016
    20 Dec 2010
    Link to this post
    Hi ManniAT,

    You cannot switch the connections, you can just keep a reference to the other database and then replace the connection string without using Visual Studio. You can have another connectionstring set in DataConfig, but it could be used for sharing data between providers.

    Regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. ManniAT
    ManniAT avatar
    9 posts
    Registered:
    08 Nov 2003
    20 Dec 2010
    Link to this post
    OK,

    I just thought that I can switch because you wrote:
    >>When you move the database to another server you can just switch the connection string from the UI.

    When I talked about having "multiple versions" of DataConfig.config I was thinking about the ability to have "multiple" web.config files.
    With that I mean the web deploy functionality where I have a general web.config and further one "partial" web.SolutionConfiguration.config - Web.Debug.config / Web.Release.config and so on.

    Is there a way to define the connection string in Web.config (instead of in DataConfig.config)?
    Or at least a setting in Web.config where I can set the connection string name (from DataConfig.config) to be used?

    The approach is simply to have different connection string just by switching the configuration in VS - like VS offers this for .NET 4.0 projects?

    A "brute force" method would be to have a "pre build action" which copies a special version of DataConfig.config to the project. But this is not like things (with .NET 4.0) normally work.
    I had to do things like this with "old .NET versions" - but since 4.0 I'm used to handle these things with the included tooling.

    Manfred
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    30 Sep 2016
    22 Dec 2010
    Link to this post
    Hello ManniAT,

    We use only the connection string from DataConfig.config and we do not look into connectionString settings in the root web.config file. We have not performed tests about scenario where you could have two modes of the DataConfig file., but I agree that it would be useful. You could try using post build events of the project that can be set through Visual Studio. There you can define a file ( DataConfig.config) which you can replace depending on the build mode.


    Regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Register for webinar
6 posts, 0 answered