Solved

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

Posted on 2011-09-08
4
212 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 74

Expert Comment

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

Expert Comment

by:khairil
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks that worked perfectly for my purposes
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now