Login problem

  • 11 years ago

    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 Then

    Response.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

Post a reply

No one has replied yet! Why not be the first?

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“The greatest performance improvement of all is when a system goes from not-working to working.” - John Ousterhout