Getting a value from a databse and storing it in a variable
I'm currently working on a project in C# in school and I have a problem.
I am using a Jet oleDbConnecton to read and store inside my Microsoft Access database.
No problem there, i can insert and store values and i can fetch the vaules and put them inside a dataGrid.
My problem is this. I have made a login form where the user needs to type in his username and password.
This is what i want to do:
I want the program to check the username inside the database and then fetch the password that is "connected" to that specific username and then store it in a variable. After that i want to check the textbox with the persons typed password with the password stored inside the variable.
How can i achive this?
This is what happens when the user pushes the login button.
leDbConnection1.Open();
oleDbDataAdapter1.SelectCommand.CommandText = "SELECT Pass FROM Larare WHERE User='"+ text_anvandarnamn.Text +"'";
oleDbDataAdapter1.SelectCommand.ExecuteNonQuery();
oleDbDataAdapter1.Fill(dataSet21,"Pass");
oleDbConnection1.Close();
//////////////////////////////////////////////
If i understand correctly the database has fetched the password and put it inside my dataset now. Assuming that this is the correct way to get the password how do i store it in a variable now?
Thanks in advance for any help.