3
Answers

Getting a value from a databse and storing it in a variable

Photo of flummer

flummer

19y
3.5k
1
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.

Answers (3)

0
Photo of Srikant Maruwada
NA 501 4.4k 7y
You can find in the Microsoft site. Please refer below link. 
 
https://code.msdn.microsoft.com/site/search?
f[0].type=topic&f[0].value=asp.net%20code%20sample%20downloads