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

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 262
  • Last Modified:

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
0
Murray Brown
Asked:
Murray Brown
1 Solution
 
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
 
nepaluzCommented:
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
 
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
Thanks that worked perfectly for my purposes
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now