Advertisement

01.03.2008 at 02:27PM PST, ID: 23057115
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

Changing connection string at runtime

Tags: Microsoft, Visual Studio 2005, C#, 2.0
I have read some of the solutions in this forum and looked at the MSDN help and cannot get this to work...

I am developing a Windows Form application in Visual Studio 2005.  I want the database connection string to be modifiable at runtime.  Now there are a couple of twists here:

1) This is all part of a Class library project, not my main application project.

2) My configuration file is not the standard Settings.settings.  I have a separate settings file (I must do this, don't ask why), called "DBSettings.settings".  When I do this, it generates the app.config file for my library (DLL) shown here in the code snippet.  

According to the MSDN documentation, all I should have to do is replace the <connectionStrings> section with:
<connectionStrings configSource="connections.config"/>
This does not work.  My app.config file is copied to the output directory, the connections.config file is.

My connections.config file looks like this:

<?xml version="1.0" encoding="utf-8" ?>
<connectionStrings>
  <add name="CardioInsight.Lib.Database.DBSettings.DBConnectionString"
      connectionString="Data Source=OTHERSYSTEM\SQLEXPRESS;Initial Catalog=CardioInsight;Persist Security Info=True;User ID=USERNAME;Password=PASSWORD"
      providerName="System.Data.SqlClient" />
</connectionStrings>
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <configSections>
        <sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
            <section name="CardioInsight.Lib.Database.DBSettings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
            <section name="CardioInsight.Lib.Database.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
        </sectionGroup>
    </configSections>
    <connectionStrings>
        <add name="CardioInsight.Lib.Database.DBSettings.DBConnectionString"
            connectionString="Data Source=CURLY\SQLEXPRESS;Initial Catalog=CardioInsight;Persist Security Info=True;User ID=USERNAME;Password=PASSWORD"
            providerName="System.Data.SqlClient" />
    </connectionStrings>
    <userSettings>
        <CardioInsight.Lib.Database.DBSettings>
            <setting name="RawDataRoot" serializeAs="String">
                <value>C:\CIData\Raw</value>
            </setting>
        </CardioInsight.Lib.Database.DBSettings>
        <CardioInsight.Lib.Database.Properties.Settings>
            <setting name="Font" serializeAs="String">
                <value>Microsoft Sans Serif, 11.25pt</value>
            </setting>
            <setting name="BackgroundColor" serializeAs="String">
                <value>Control</value>
            </setting>
            <setting name="WindowStyle" serializeAs="String">
                <value>Office2007Black</value>
            </setting>
            <setting name="TabFont" serializeAs="String">
                <value>Arial, 11.25pt, style=Bold</value>
            </setting>
            <setting name="ButtonFont" serializeAs="String">
                <value>Arial, 11.25pt, style=Bold</value>
            </setting>
            <setting name="Display" serializeAs="String">
                <value>1</value>
            </setting>
        </CardioInsight.Lib.Database.Properties.Settings>
    </userSettings>
</configuration>
Start your free trial to view this solution
Question Stats
Zone: Programming
Question Asked By: johneanderson
Solution Provided By: vadimrapp1
Participating Experts: 4
Solution Grade: B
Views: 409
Translate:
Loading Advertisement...
01.03.2008 at 02:38PM PST, ID: 20577805

Rank: Guru

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
01.03.2008 at 02:57PM PST, ID: 20577969

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
01.04.2008 at 12:10PM PST, ID: 20585649

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
01.04.2008 at 12:23PM PST, ID: 20585750

Rank: Master

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
01.04.2008 at 12:39PM PST, ID: 20585882

Rank: Master

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
01.04.2008 at 01:02PM PST, ID: 20586089

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
01.04.2008 at 01:04PM PST, ID: 20586109

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
01.21.2008 at 09:08AM PST, ID: 20707575

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
01.21.2008 at 09:28AM PST, ID: 20707759

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
01.21.2008 at 09:51AM PST, ID: 20707926

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
01.21.2008 at 10:36AM PST, ID: 20708250

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
20080236-EE-VQP-29 / EE_QW_2_20070628