I have a login system, that will have an option to change a user password if forgotten once they answer their security question correctly.
Everything is working fine, except I'm unsure how to determine if it was successful or not.
If TextBox1.Text = TextBox2.Text Then
Dim conn As MySqlConnection
conn = New MySqlConnection("server=localhost; user id=root; password=; database=testing")
Dim username As Boolean = True
conn.Open()
Dim sqlquery As String = "UPDATE user SET password='" & TextBox1.Text & "' WHERE id='" & frmLogin.CurrentUserID & "';"
Dim data As MySqlDataReader
Dim adapter As New MySqlDataAdapter
Dim command As New MySqlCommand
command.CommandText = sqlquery
command.Connection = conn
adapter.SelectCommand = command
data = command.ExecuteReader
Dim i As Integer = command.ExecuteNonQuery()
If (i > 0) Then
MessageBox.Show("Success!")
Else
MessageBox.Show("Failed!")
End If
data.Close()
conn.Close()
Else
MsgBox("Passwords must match!")
End If
It should show a message box saying "Success!" if it worked and "Failed!" if not. I'm getting an error --> 'There is already an open DataReader associated with this Connection which must be closed first.'