Solved

How to store and save variables without using constants

Posted on 2008-10-22
3
430 Views
Last Modified: 2013-11-07
I have an application that needs a username and password, and both are entered in a login form at the beginning of the the application startup. The problem is, the application causes the system to restart several times, and I need it to save that username and password that was entered at the beginning of the application so that way it can keep using those values later after the restart.
0
Comment
Question by:bryanpilger
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 13

Accepted Solution

by:
jeebukarthikeyan earned 500 total points
ID: 22775977
hi,

u can use the session objects fr storing the user name and password ,which can be accessed through the application

Session.Add("UserName",txtUserName.Text);
Session.Add("Password",txtUserName.Text);

b u d d h a
0
 
LVL 8

Expert Comment

by:jorgesv13
ID: 22775996
I think you can save them on the Windows Registry:

SaveSetting("MyApp","MySection","Username",txtUsername.Text)
SaveSetting("MyApp","MySection","Password",txtPassword.Text)

Then, you can retrieve it using GetSetting:
GetSetting("MyApp", "MySection", "Username")

Additionally, you may want to store also the current DateTime, so you can also check if there's been not too much time since this data was saved in the Registry
0
 
LVL 26

Expert Comment

by:Anurag Thakur
ID: 22776613
it depends on your project type (web application or a windows application)
if its a web application then you can use registry or dupt the settings to an XML file and on rebooting of your machine you can read the values back again

in case of a windows application then either registry or an XML file or you can save the settings to the application configuration file too.
0

Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

632 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