Question

I just started working with SQL and now what I need is to make a database for my C# application which will save user names and passwords. Think of it like a password reminder.

Anyway, what I think I need to do is: I need to create a SQL database which will the application only use to save data. It should not need SQL Server to be installed on the machine.

I searched over the internet but no result, all of them require the use of SQL Server, please could you just provide me the steps to do so, or any resource and thanks a lot.

Was it helpful?

Solution

You need to decide how you want to save your data. You can save the data in an XML file, a plain text file, or anything else.

The reason you're seeing so many examples of people using SQL is because relational databases have already solved a lot of the issues you're likely to run into when storing and retrieving data. That means in most cases, it's much easier to use an SQL database (even a lightweight embedded one) than to try to come up with your own library for retrieving and saving data.

A note about saving passwords

Bear in mind that any data you save on a client's computer is going to be accessible to that client. You can use tricks to make it very difficult for someone to get to that data, but there's nothing your program can do that a clever hacker won't be able to mimic. The only way to avoid letting users see the stored passwords would be to make the user provide a "master" password that gets converted into a key that is used to encrypt the other passwords. This way, only users that know this master password would still be able to get the stored data.

Storing data in a relational database is not sufficient to prevent users from accessing that data.

OTHER TIPS

You could use SQL Compact ( http://msdn.microsoft.com/en-us/data/ff687142 ) to avoid installing SQL Server.

You could also go for sqlite.org.

Your requirements of "I want a database" and "I don't want [database]-server" are difficult to match.

If you have a database without a database-server, you have a lump of in-accessible data.

If you want to use a SQL database, you will need a SQL server. Or, you will have to re-implement one in order to use the database.

There are a number of small, open-source SQL servers available. I've worked with HSQL.

you might want to take a look at the SO question SQL-lite vs HSQL-db.

If all you want is one file that can't be read easily, try encrypting the data, and use either text or XML files for storage.

You do need a database to be installed on your computer if you want to use SQL to query the data. It need not be SQL Server, but definitely some kind of database. You can download MySQL, Sql Server Express or any of the free database products available out there.

Once you have that up and running, querying the database from c# is fairly simple and it may be easier for you to follow this tutorial, with has similar functionality to what you need.

You could always use a CSV (Comma Separated Value) file as your "database" I found a link that could help you with this Query CSV using LINQ C# 2010

EDIT: When it comes to security, you can always use something like MD5. It can turn a password into a an irreversible hash. This way no one will ever be able to see others passwords

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top