deception1
deception1

Reputation: 1767

Access SQL Server database with c# in WPF?

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

Upvotes: 0

Views: 3260

Answers (3)

Seekeer
Seekeer

Reputation: 1394

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

Upvotes: 0

user1082916
user1082916

Reputation:

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

Upvotes: 1

Random Dev
Random Dev

Reputation: 52280

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...

Upvotes: 0

Related Questions