Solved

How to store and save variables without using constants

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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

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)…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

734 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