Solved

How to store and save variables without using constants

Posted on 2008-10-22
3
388 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

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 …
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

763 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

9 Experts available now in Live!

Get 1:1 Help Now