Solved

VB.net - holding string variable that is used all over the application

Posted on 2011-09-08
4
233 Views
Last Modified: 2012-05-12
Hi

In VB.net 2010 I load the path of a database into a variable
declared as follows at the top of a standard module

 Public sPath  As String

Will this be held in that variable while the application is running or is there a better place to store
0
Comment
Question by:murbro
4 Comments
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 36504921
Sounds like you would want a configuration setting. Have you considered adding it to the config file?
0
 
LVL 13

Expert Comment

by:khairil
ID: 36505058
Hi,

What DB are you using, is it PATH of database or Connection string?

You can always put public declared variables by adding a Module and put declaration in there. It can now be access/change from anywhere in the project.

For database connection, it is better to store in in <app>.config file. Since it is a plain text and your connection string consist userid and password, it must be protected, here is how to do, http://msdn.microsoft.com/en-us/library/89211k9b(v=vs.80).aspx
0
 
LVL 17

Accepted Solution

by:
nepaluz earned 500 total points
ID: 36505161
May be an issue if you wantthe variable utilized in another class where you have to expressly pass its value. Utilize My.Settings to hod your string variable and you can reference it directly (from any class without expressly  passing it).
0
 

Author Closing Comment

by:murbro
ID: 36505856
Thanks that worked perfectly for my purposes
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

786 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