I am building a .net website and want to be able to use a login control to access a page where the username and password are taken from an existing database.
The code I have used is below:
Now this works great.... as long as you are the first person in the database table. For some reason the datareader doesn't read all the rows to match the username and password entered.
Any help would be greatly appreciated.
Protected Sub Login1_Authenticate(ByVal sender As Object, ByVal e As AuthenticateEventArgs)
Dim Authenticated As Boolean = False
Authenticated = SiteLevelCustomAuthenticationMethod(Login1.UserName, Login1.Password)
e.Authenticated = Authenticated
If Authenticated = True Then
Private Function SiteLevelCustomAuthenticationMethod(ByVal UserName As String, ByVal Password As String) As Boolean
Dim boolReturnValue As Boolean = False
' Insert code that implements a site-specific custom
' authentication method here.
' This example implementation always returns false.
Dim strConnection As String = "server=dtpxp-skumari;database=master;uid=sa;pwd=;"
Dim Connection As New SqlConnection(strConnection)
Dim strSQL As String = "Select * From Employee"
Dim command As New SqlCommand(strSQL, Connection)
Dim Dr As SqlDataReader
Dr = command.ExecuteReader()
If (UserName = Dr("name").ToString()) And (Password = Dr("Password").ToString()) Then
boolReturnValue = True