1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| Dim sqlcon As New SqlConnection("Server=localhost ; DataBase=mailing ; Integrated Security=SSPI;")
sqlcon.Open()
Dim struser As String = "Select login,password from administrateur where login = @UserName"
Dim sqlcom As New SqlCommand(struser, sqlcon)
sqlcom.Parameters.AddWithValue("@UserName", Me.TextBox1.Text)
Dim dr As SqlDataReader
dr = sqlcom.ExecuteReader()
If dr.HasRows = False Then
MsgBox("Identifiant incorrect", MsgBoxStyle.Information, "Atention")
Me.TextBox1.Focus()
Exit Sub
End If
dr.Read()
If Me.TextBox1.Text = dr("login") And Me.TextBox2.Text = dr("password") Then
MsgBox("Access Granted", MsgBoxStyle.Information, "Confirmation")
Me.Hide()
Form2.Show()
Else
MsgBox("tu n as pas le droit d acceder au system", MsgBoxStyle.Critical, "Access Denied")
End If
sqlcon.Close() |
Partager