I am using the login control in ASP.NET. When I run the program an error msg "Incorrect syntax near the keyword 'User' " appeared in the debugging mode. I have no idea what is the problem. Anyone know what is wrong with my code?
Protected Sub Login1_Authenticate(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.AuthenticateEventArgs) Handles Login1.Authenticate
If (ValidateLogin(Login1.UserName, Login1.Password)) Then
e.Authenticated = true
else
e.Authenticated = false
End If
End Sub
Private Function ValidateLogin(ByVal username As String, ByVal password As String) As Boolean
Dim boolReturn As Boolean = False
Dim conStr As SqlConnection = New SqlConnection(ConfigurationManager.ConnectionStrings("testingConnectionString").ConnectionString)
Dim cmdStr As String = "SELECT username, password FROM User"
Dim cmd As SqlCommand = New SqlCommand(cmdStr, conStr)
Dim dr As SqlDataReader
conStr.Open()
dr = cmd.ExecuteReader() 'ERROR IS INDICATED HERE
While dr.Read()
If (username = dr("username").ToString()) And (password = dr("password")) Then
boolReturn = True
dr.Close()
conStr.Close()
Return boolReturn
End If
End While
dr.Close()
conStr.Close()
Return boolReturn
End Function