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 29 30 31 32 33
| Protected Sub Login1_Authenticate(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.AuthenticateEventArgs) Handles LoginUser.Authenticate
Dim username As String
Dim pwd As String
Dim pName As String
username = LoginUser.UserName
pwd = LoginUser.Password
pName = ""
Dim strConn As String
strConn = WebConfigurationManager.ConnectionStrings("basedossierConnectionString").ConnectionString
Dim Conn As New SqlConnection(strConn)
Conn.Open()
Dim sqlUserName As String
sqlUserName = "SELECT username, password FROM dbo.utilisateur"
sqlUserName &= " WHERE (username = @UserName"
sqlUserName &= " AND password = @Password)"
Dim com As New SqlCommand(sqlUserName, Conn)
com.Parameters.AddWithValue("@UserName", username)
com.Parameters.AddWithValue("@Password", pwd)
Dim CurrentName As String
CurrentName = CStr(com.ExecuteScalar)
If CurrentName <> "" Then
Session("UserAuthentication") = username
Response.Redirect("Nouveau.aspx")
Else
Session("UserAuthentication") = ""
End If
End Sub |
Partager