Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 109667
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T02:06:20+00:00 2026-05-11T02:06:20+00:00

You can change the connection string at run-time like this. You make the connection

  • 0

You can change the connection string at run-time like this. You make the connection string setting available for writing as a separate property inside the MySettings class:

Partial Friend NotInheritable Class MySettings     Public WriteOnly Property RunTimeConnectionString()         Set(ByVal value)             My.Settings('MyConnectionString') = value         End Set     End Property End Class 

Then, in some place when the application is being initialized (before using any table adapters of typed datasets), write something like:

My.Settings.RunTimeConnectionString = My.Settings.ProductionConnectionString 

Where ProductionConnectionString is a simple String setting. It is a User Scope setting so every user can change it (by assigning a value to it, similar to the code above) and save it by calling My.Settings.Save()

This code works well for connection strings which were initially created in the main project and stored in it’s settings (= app.config file).

The connection string in the app.config actually has a longer name: MyApp.MySettings.MyConnectionString.

When you have a connection string stored in the app.config in a class library project, and reference that project in the main project, the app.config files will somehow be merged, so the class library has it’s settings.

The thing that don’t know how to do, is change a setting from the class library at run-time. I could copy the connection string setting from the class library to the main project’s app.config. I must keep the same name, which looks something like: MyClassLibrary.My.MySettings.MyConnectionString.

Can the same principle I showed above be somehow applied to this second connection string?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T02:06:21+00:00Added an answer on May 11, 2026 at 2:06 am

    I tested a little more, and found out that the same solution can be used inside a class library.

    I made a new class (in the class library) with a shared (static) method like this:

    Public Class MySettingsChanger     Public Shared Sub SetConnectionString(ByVal cnnString As String)         My.Settings.RunTimeConnectionString = cnnString     End Sub End Class 

    And extended the MySettings class (in the class library) the same way as in the main project:

    Namespace My     Partial Friend NotInheritable Class MySettings         Public WriteOnly Property RunTimeConnectionString()             Set(ByVal value)                 My.Settings('MyConnectionString') = value             End Set         End Property     End Class End Namespace 

    At least it works in my case. The name of the connection in the main project and in the class library is the same only (the short name, not the whole ProjectNamespace.MySettings.ConnectionName). I haven’t tested with having a different name of the connection in the class library, but think it should not matter.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 247k
  • Answers 247k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer put the incoming requests into a queue use one thread… May 13, 2026 at 8:45 am
  • Editorial Team
    Editorial Team added an answer Have a look at tapestry web-framework. from code-quality perspective one… May 13, 2026 at 8:45 am
  • Editorial Team
    Editorial Team added an answer One of the first players in the faceted search domain… May 13, 2026 at 8:45 am

Related Questions

I am looking to integrate ELMAH into an existing ASP.NET application to further support
Let's say I have a simple class Cat in C#, with a Name property
I plan to be storing all my config settings in my application's app.config section
I need to know where and how application settings (connections string) could be stored

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.