To see how to access your MySql database read through this topic:
Click here PsychoCoder lays it out very nicely here and it should get you going.
Your SELECT statement won't work here.
'SELECT *' will return everything in that table.
What you need to do is compare the username entered to the username in your database, and the password entered to the password in your database and if they match they are allowed access.
CODE
"SELECT COUNT(*) FROM login WHERE (Username=?username) AND (Password=?password)";
This does a count where the variables entered match the database entry and return a count (you're looking for 1 which is a match or 0 which fails) The ?password is the password that is entered. I had a similar question which the guys here at DIC helped to resolve:
Click here Read through this thread.
Also when you open your connection, always make sure you close it again, as quickly as possible, and wrap it in a try, catch, finally block.
csharp
try
{
//open and execute command
conn.Open();
cmd.ExecuteScalar;
}
catch(Exception ex)
{
// catch any errors here
}
finally
{
//always do this
conn.Close();
}
Hope this helps.