| Author: santhosh babu 16 Nov 2006 | Member Level: Bronze | Rating: Points: 2 |
it is erroring out becoz we are not fetching username in the query which fills the reader. so accessing username from reader will give error.
|
| Author: rajahram 16 Nov 2006 | Member Level: Bronze | Rating: Points: 2 |
Function check(ByVal UserName As String, ByVal Password As String) As Boolean Dim boolReturnValue As Boolean = False Dim strSQL As String = "Select username,Pwd, Activestatus, Loginstatus From Employee where Username= '" & UserName & "'" Connection = New SqlConnection(strConnection) 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("Pwd").ToString) Then If Dr.Item(2) = "Y" Then boolReturnValue = True End If End If Dr.Close() Return boolReturnValue End While
End Function
Call the above function in FormLoad of Login Page --------------------------------------------------
Dim Authenticated As Boolean = False Authenticated = check(UserName, Password)
If Authenticated = True Then Response.Redirect("link.aspx") endif
|
| Author: shankar 17 Nov 2006 | Member Level: Bronze | Rating: Points: 2 |
HI, Use This one,
cmd(SqlQry,con) dr=cmd.ExecuteReader() If Not dr.Read() then MsgBox("InValidUser") Else Response.Redirect("Samp.aspx")
|
| Author: Roopesh Babu Valluru 17 Nov 2006 | Member Level: Gold | Rating: Points: 2 |
i dunno VS.2005....so i am sending th code in 2003...hope this wil give u an idea....
dim con as new sqlconnection("connection string") dim cmd as new sqlcommand("select pwd from <table name> where userid='"<txtbox name of user id>"'",con) dim password as string password="" password=cmd.executescalar() if password=<txtbox.text(password holding textbox)> then <do some thing> else msgbox("User id and pasword doesnot match")
**********************************************
this is up to my mind...hope it wil be helpful...
|