Hello, I'm writing an aspx form and need to check the login so if the user exist he can upload file if doesn't then he must register, I'm using the login control in visual studio but it's not working. I use this code:
Protected Sub Login1_Authenticate(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.AuthenticateEventArgs) Handles Login1.Authenticate
Dim Authenticated As Boolean = False
Authenticated = SiteLevelCustomAuthenticationMethod(Login1.UserName, Login1.Password)
e.Authenticated = Authenticated
If Authenticated = True ThenResponse.Redirect("login_true.aspx")
End If
End Sub
Private Function SiteLevelCustomAuthenticationMethod(ByVal UserName As String, ByVal Password As String) As Boolean
Dim boolReturnValue As Boolean = False
'Dim strConnection As String = "datasource"Dim Connection As SqlConnection = New SqlConnection(conn)
Dim strSQL As String = "Select * From Table1"Dim command As SqlCommand = New SqlCommand(strSQL, Connection)Dim Dr As SqlDataReader
Connection.Open()
Dr = command.ExecuteReader
While Dr.Read
If ((UserName = Dr("UserName").ToString) And (Password = Dr("Pass").ToString)) Then
boolReturnValue =
True
End If
Dr.Close()
Return boolReturnValue
End While
End Function
I get this code from the internet but it doesn't work for me, any ideas
No one has replied yet! Why not be the first?
Sign in or Join us (it's free).