Advertisement

08.19.2006 at 11:18AM PDT, ID: 21960324
[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!

7.6

How to change connectionstrings that are readonly in app.config

Asked by RadicalSoftwareSolutions in Microsoft Visual Basic.Net

Tags: ,

OK Here goes.

I have developped a VB.NET 2005 application which includes the fancy new "drag 'n drop" DataSet tool. When you first create a new dataset VB writes the connection string into the app.config file (visible through myproject.settings) as an "application scope" value. Application scope values are read only at runtime which is all well and good while I'm developping and my development server is available but completely useless when it comes to releasing the application to clients.

How can you change these connection strings at run time??

I've been searching now for ages to a proper answer to this question and a lot of time the answer is "you shouldn't do that....microsoft intended these to be fixed etc,etc" which is avoiding the issue. These values need to be changed!!!

One client has a need to set these values on a "per user" basis as the databases are replicted out to branch offices and the connectionstring needs to point at the replicated database.

The answer ould seem to be to change the values in the <programname>.exe.config file that is created in the user's directory and apply these in the settings.SettingsLoaded function but how exactly can this be done?

Simply assigning these values to a User Scope won't work as VB will continue to look at the application scope value for any updates effected on the dataset

I have seen Q_20954883 but it doesn't appear to address changing the connectionstring values (I accept that the app will need to be restarted the first time these are changed) as they don't appear to follow the normal XML structure rules.

Here's part of the app.config file...(values have been changed to protect the innocent)
<?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=123456789" >
            <section name="System2.My.MySettings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=123456789" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
        </sectionGroup>
    </configSections>
    <connectionStrings>
        <add name="Systemx.My.MySettings.ConnectionString"
            connectionString="Data Source=SQLSERVER;Initial Catalog=SystemXDB;Persist Security Info=True;User ID=xy;Password=abc"
            providerName="System.Data.SqlClient" />
        <add name="Systemx.My.MySettings.ConnectionString_OLE"
            connectionString="Provider=SQLOLEDB;Data Source=SQLSERVER;Initial Catalog=SystemXDB;Persist Security Info=True;User ID=xy;Password=abc"
            providerName="System.Data.OleDb" />
    </connectionStrings>
    <userSettings>
        <Systemx.My.MySettings>
            <setting name="Database" serializeAs="String">
                <value>SystemxDB</value>
            </setting>
         <setting name="RunBefore" serializeAs="String">
                <value>False</value>
            </setting>
        </System2.My.MySettings>
    </userSettings>
</configuration>


I'm assigning maximum points to this as there are a lot of other developers asking the same question on lots of other such sites but please do not say "you shouldn't be doing this!!!" - unless of course there is another way of getting VB to connect the dataset to a runtime connectionstring



Many thanks

IanStart Free Trial
 
Loading Advertisement...
 
[+][-]08.19.2006 at 04:59PM PDT, ID: 17349636

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08.19.2006 at 11:12PM PDT, ID: 17350545

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08.20.2006 at 12:11AM PDT, ID: 17350669

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08.20.2006 at 01:54AM PDT, ID: 17350793

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08.20.2006 at 04:35AM PDT, ID: 17351113

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08.20.2006 at 08:32PM PDT, ID: 17353494

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Microsoft Visual Basic.Net
Tags: change, connectionstring
Sign Up Now!
Solution Provided By: Ready1
Participating Experts: 2
Solution Grade: A
 
 
[+][-]08.21.2006 at 01:05AM PDT, ID: 17354186

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08.21.2006 at 01:52AM PDT, ID: 17354367

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08.21.2006 at 04:19AM PDT, ID: 17354899

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32