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

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
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAsked:
Who is Participating?
 
nepaluzConnect With a Mentor Commented:
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
 
käµfm³d 👽Commented:
Sounds like you would want a configuration setting. Have you considered adding it to the config file?
0
 
khairilCommented:
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
 
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
Thanks that worked perfectly for my purposes
0
All Courses

From novice to tech pro — start learning today.