0

I was researching around the internet and I came across bits and pieces. I want to create a small app (login page /already done/ ). Previously I used something like this

if ( usename!= foo and pass !=bar) messageboxshow wrong username and password

A super-simple solution.

However I now have to use a SQL Server 2008 database table to verify the username and password. Sadly I don't know how.

I tried the examples posted here http://www.daniweb.com/software-development/csharp/threads/368722

and the official MSDN but I couldn't get it to work.

Is there a very simple solution for this.

And if there is not how would I handle all my database connections using data access layers, which I think is along the lines of tiered programming

3 Answers 3

1

By using LINQ to SQL, you can use the LINQ technology to access SQL database........It will give simple and shorter way to play with database....

For implementation of LINQ to SQL in your project, Get started with following link:

http://msdn.microsoft.com/en-us/library/bb399398.aspx

Sign up to request clarification or add additional context in comments.

3 Comments

it's more or less the same as using EF nowadays and if you start to learn this stuff you should go EF as Microsoft supports this for future development (Linq2Sql will not be developed further)
@Carsten König deception asked not about learningn ORM staff, but about simple app and "very simple solution for this", so in such case using linq2sql is quit reasonable. As for learning I would recommend using NHibernate instead of EF, but this is offtopic.
so linq2sql is not a ORM? Maybe not as full-fledged as the other two you mentioned but this is why I would not recommend a beginner starting there only to have to learn the next one if things are getting more involved - as for NHibernate VS EF: you might not be allowed to use open-source code and even if you might not want to have the additional setup - EF is out of the box and therefore IMHO a very reasonable way to go
0

Have a look at the EntityFramework - a good starting-point is this: Getting Started

Concerning the task you are about to implemet allow me to give you a short warning: This might be very delicate data (username/passwords) and you will not want to save the password as clear-text into the database. To give a bit of security you have to hash the passwords (using a cryptographic hash-algorithm like SHA) and only compare the hashed user-entered string to this database-hash. This way if someone steals your database-data, he cannot get the real passwords (it's very hard to find a matching string, that hashes to the same value - that's what those algorithms are for). There are lots of ways to make this more secure (adding random-bytes - seeds - and so on) but you should do this at the very least...

1 Comment

I will try to do that.Currently my code executes past the login window regardles of the correct username or password is given or not
0

For easy access to database data from code you should use ORM. Most simple one is Linq to SQL as akash88 have mentioned. If you need only simple operation as reading from specified table it would be best choice. But if in future there would be more complicated task you should use either NHibernate or Entity Framework

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.