1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim queryString As String = "SELECT id FROM `authentification` WHERE username='" & _
TxtLogin.Text.Trim & "' and password='" & TxtPassword.Text.Trim & "'"
Dim conn As New MySqlConnection("server=localhost" + ";username=root" + ";password=mirihane" + ";database=Avocat" + ";")
Dim myCommand As New MySqlCommand(queryString, conn)
myCommand.CommandType = CommandType.Text
conn.Open()
Dim myReader As MySql.Data.MySqlClient.MySqlDataReader
myReader = myCommand.ExecuteReader()
If myReader.HasRows Then
While myReader.Read()
username = TxtLogin.Text
password = TxtPassword.Text
id = myReader.GetString(0)
Form2.Show()
End While
Else
MsgBox("login ou mot de passe erronés!", MsgBoxStyle.Critical, "Connexion échoué")
End If
myReader.Close()
conn.Close()
End Sub |
Partager