Solved

How to store and save variables without using constants

Posted on 2008-10-22
3
398 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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Definitions and default visual studio colors 5 58
Interview questions for support of a legacy ASP.NET site 4 37
Close tabpage of custom control 9 23
ASP.NET 5 Templates 2 65
Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
A short film showing how OnPage and Connectwise integration works.

914 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

14 Experts available now in Live!

Get 1:1 Help Now