Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Storing a Connection String in My.Settings?

Posted on 2014-09-16
6
Medium Priority
?
83 Views
Last Modified: 2014-09-17
I have not used the My.Settings feature very much so I'm not clear on all it's rules.

I have a setting called "strDBConnection" established in My.Settings. It's defined as "Connection String" along with it's value.

In design mode, I have a statement that won't work (see attachment). How do I resolve this?

Thanks!
Screenshot.jpg
0
Comment
Question by:BlakeMcKenna
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 1

Expert Comment

by:Andrea Antonangeli
ID: 40325678
You must define the setting as "User" to avoid the readonly attribute of the property you define in My.Settings

You probably have defined it as "Application"
0
 

Author Comment

by:BlakeMcKenna
ID: 40325715
Yes, I do but I need the scope of that variable to be "Application". Is there a way to dynamically set that setting "strDBConnection" to where it will persist until changed again?
0
 
LVL 1

Expert Comment

by:Andrea Antonangeli
ID: 40325831
I'm afraid there is no way to change the value of "strDBConnection" if you define it as "Appication".
It is Readonly by design.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:BlakeMcKenna
ID: 40326053
Actually, you can do it. I've seen the code before but don't have it nor do I remember it...
0
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 2000 total points
ID: 40327319
Connection strings should really go in the <connectionStrings> section of your app.config--it's a commonly accepted convention. You can access the values by way of:

Dim conString As String = System.Configuration.ConfigurationManager.ConnectionStrings("con string name").ConnectionString

Open in new window


...once you've added a reference to System.Configuration.dll.
0
 

Author Closing Comment

by:BlakeMcKenna
ID: 40327951
Thanks KaufMed...that worked great!
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

704 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question