Solved

How to store and save variables without using constants

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

825 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