Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Storing a Connection String in My.Settings?

Posted on 2014-09-16
6
Medium Priority
?
84 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
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…

927 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