Imports System Imports System.Collections.Generic 'Imports System.Ling Imports System.Web Imports System.Web.UI Imports System.Web.UI.WebControls Imports System.Data.SqlClient Partial Class _Default Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Label1.Text = "" 'SqlDataSource1.ConnectionString = "Data Source=ML0002298641\SQLEXPRESS;Initial Catalog=dbFluor;Integrated Security=True" If Not Me.IsPostBack Then ViewState("LoginErrors") = 0 End If End Sub 'Protected Sub Login1_Authenticate(ByVal sender As Object, ByVal e As AuthenticateEventArgs) ' If YourValidationFunction(Login1.UserName, Login1.Password) Then ' e.Authenticated = true; ' Login1.Visible = False ' Label1.Text = "Successfully Logged In" ' Else ' e.Authenticated = False ' End If 'End Sub Protected Sub Login1_LoginError(ByVal sender As Object, ByVal e As EventArgs) If ViewState("LoginErrors") Is Nothing Then ViewState("LoginErrors") = 0 End If Dim ErrorCount As Integer = CInt(ViewState("LoginErrors")) + 1 ViewState("LoginErrors") = ErrorCount If (ErrorCount > 3) AndAlso (Login1.PasswordRecoveryUrl <> String.Empty) Then Response.Redirect(Login1.PasswordRecoveryUrl) End If End Sub Private Function YourValidationFunction(ByVal UserName As String, ByVal Password As String) As Boolean Dim boolReturnValue As Boolean = False Dim strConnection As String = "Data Source=10.16.67.73;Initial Catalog=TestSQL;Integrated Security=True" '"server=.;Database=Database;uid=sa;pwd=wintellect;" 'Dim strConnection As String = "Server=.\SQLExpress;DataBase=TestSQL;Integrated Security=SSPI" Dim sqlConnection As New SqlConnection(strConnection) 'Dim SQLQuery As String = "SELECT LogName, LogPass FROM tblLog" Dim SQLQuery As String = "SELECT LogMe.*, User_ID AS Expr1, Name AS Expr2, Cost_Center AS Expr3, Role_ID AS Expr4, Password AS Expr5 LogName = '" & Login1.UserName & "' AND LogPass = '" & Login1.Password & "' " Dim command As New SqlCommand(SQLQuery, sqlConnection) Dim Dr As SqlDataReader sqlConnection.Open() Dr = command.ExecuteReader() While Dr.Read() If (UserName = Dr("LogName").ToString()) And (Password = Dr("LogPass").ToString()) Then boolReturnValue = True End If Dr.Close() Return boolReturnValue End While Return boolReturnValue End Function Protected Sub Login1_Authenticate1(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.AuthenticateEventArgs) Handles Login1.Authenticate If YourValidationFunction(Login1.UserName, Login1.Password) Then ' e.Authenticated = true; Login1.Visible = False Label1.Text = "Successfully Logged In" Else e.Authenticated = False End If End Sub End Class
Dr = command.ExecuteReader() While Dr.Read() If (UserName = Dr("LogName").ToString()) And (Password = Dr("LogPass").ToString()) Then boolReturnValue = True End If Dr.Close() Return boolReturnValue End While
If (UserName == Dr("LogName").ToString()) And (Password == Dr("LogPass").ToString()) Then
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)