views:

180

answers:

6

HI, I was wondering is there any way to store data, like say I wanted to make a login form and save the usernames and passwords, without using a database or .txt file? Seems like alot of work to set up stuff like that, for something simple, and I was just wondering if there was another way. :)

And if any one has some tutorials on how to use a database Access/Sql/Local Database please post.

+2  A: 

You have to put it somewhere to persist it, and I'm not sure how a text file is "a lot of work", especially when compared to a database. Since you used the c# tag, I guess you could put it in the registry if you want, which doesn't require making any new files on the disk.

Donnie
Well I mean a .txt file isn't alot of work but some one could just open it and read it, and I wouldn't want to create a .txt file for every user that is created.
Tanner
after recently spending several hours cleaning the registry from a botched McAfee enterprise installation i would strongly suggest against using the registry ;-)
Anders K.
@Anders - yeah, I misread the original question as saving the state of an application, like the last username used to login on a form. Putting an entire database of users in the registry would be insanity.
Donnie
+1  A: 

Databases are way better than text files, especially when you're well-organized. For example, having a database table with Username and Password columns [ie:

 +------------+------------+
 + Username   + Password   +
 +------------+------------+
 + Blargh     + Badajaja   +
 + Trinkle    + GALUMPADA  +
 +-------------------------+

is much more legible than
6Blargh8Badajaja7Trinkle9GALUMPADA
or
Blargh^]Badajaja^]Trinkle^]GALUMPADA

MySQL is easy to work with using C#, just use google to find a ton of guides/tutorials.

ItzWarty
You **MUST NOT** store passwords in plain text.
SLaks
... especially if your password is "Dinkle". Nobody wants to read that.
Chris Dwyer
You know I actually didn't know that "dinkle" meant... erm. It sounds cool when next to trinkle. Anyways, time to change where I live on facebook. It was set to Trinkledinkle, heh... Oh, and @SLaks, I can write up an implementation of ROT13 for you easily. Don't worry.
ItzWarty
+1  A: 

If you want to scale, I would use a database. A really large text file can be expensive to read in all the time, and I just personally like using databases more for situations like this.

Here's a link to a tutorial: http://msdn.microsoft.com/en-us/library/ms247257(VS.80).aspx

Security wise, both will work, you can encrypt both, however being able to encrypt/decrypt row by row without a whole bunch of extra code is nice.

Lerxst
+1  A: 

Your question is confusing. Sounds almost like you're asking how to save the data without saving the data.

Maybe you're just not wanting to use a full RDBMS like SQL Server or Oracle or even SQL Server Express? Then there's SQL Lite

JC
OK, maybe I should put it this way, is there a way to store a variables value? Like if this windows should run on start-up of the program or not to run. You know what I mean so it can remember stuff like that or what color background you had chosen for the app, and different stuff like that
Tanner
+2  A: 

From your comment to JC, it sounds like you're talking about persistence, which is the idea of saving the state of an object for a latter run. (Mentioning logins threw everyone off, I think). I'm not much of a C# hacker, but some quick googling turned up this.

It sounded like you might be looking for application settings specifically, tutorial here.

academicRobot
+4  A: 

For me this is a job for Settings.

kenny