Reputation: 39
I am creating a forgot password feature for a login form. If the users username and email match whats in the database then an email containing their password needs to be sent to their email address. Once my select statements grabs the password I do not know how to convert that over into the body of the email.
cmd2.CommandText = "Select Password from tblLogin where Username = '" & UsernameTextBox.Text & "' and EmailAddress = '" & EmailAddressTextBox.Text & "'"
pass = cmd2.ExecuteReader
If pass.HasRows Then
Do While pass.Read()
EmailMessage.Body = "Here is your password:"
Loop
Else
Console.WriteLine("No rows found.")
End If
The only thing I can think of doing is this: EmailMessage.Body = ("Here is your password: " & pass) However I still need to figure out how I can convert pass into a string containing the query result.
Upvotes: 0
Views: 1329
Reputation: 55049
Since you only want the one value from the DB, look at ExecuteScalar instead of ExecuteReader
.
However, as Alex commented, unencrypted passwords is really not a good idea.
Upvotes: 0