Wrox Programmer Forums
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 21st, 2004, 12:54 PM
Registered User
 
Join Date: Dec 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default DataReader w/ If Statement

I am working on a login screen, but having issues w/ my iterations. I want someone who is logging in to only have 3 chances before it redirects them to the forgot password page... Below is my code, problem is; it kicks right out of the if statement to the forgot pwd page....
Please help; THANKS

***********************************************

Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click


        Dim Dr As System.Data.SqlClient.SqlDataReader
        Dim user, pwd As String
        Dim Count As Integer = 0
        user = Me.txtUser.Text
        pwd = Me.txtPwd.Text
        Session("Username") = user
        Session("Password") = pwd
        SqlConn.Close()
        SqlConn.Open()
        Dr = SqlComm.ExecuteReader


        While Dr.Read
            Session("FirstName") = Dr("DTFName").ToString
            Session("LastName") = Dr("DTLName").ToString
            If Count > 3 Then
                If (user = Dr("DTLoginID").ToString And pwd = Dr("DTPassword").ToString) Then
                    Response.Redirect("Broadcast.aspx")

                ElseIf (user <> Dr("DTLoginID").ToString Or pwd <> Dr("DTPassword").ToString) Then
                    Me.lblError.Text = "Invalid Username/Password; Please Try Again"
                    Count = Count + 1

                    'ElseIf (user <> Dr("DTLoginID").ToString And pwd = Dr("DTPassword").ToString) And Count <= 3 Then
                    ' Me.lblError.Text = "Invalid Username/Password; Please Try Again"
                    ' Count = Count + 1
                End If
            ElseIf Count < 3 Then
                Response.Redirect("ForgotPwd.aspx")
            End If
            lblCount.Text = Count
        End While



    End Sub

************************************************** ******

THANKS Bunches :D
 
Old December 21st, 2004, 05:43 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

A: Don't you mean to test it this way?

            If Count < 3 Then
                ...
            ElseIf Count = 3 Then
                Response.Redirect("ForgotPwd.aspx")
            End If

B: Where are you retrieving the count value from the textbox? You probably should have something like this:

Dim Count As Integer = 0
If lblCount.Text.Length > 0 Then
     Count = CType(lblCount.Text, Integer)
End If
 
Old December 23rd, 2004, 06:16 AM
Authorized User
 
Join Date: Sep 2004
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to nashnash
Default

Plz add one hidden field in your .aspx page like this
<input type="hidden" name="hidCount" value="0" runat="server" ID="hidCount">
.change the values and names here and it will work fine.
---------------------------------------
        Dim strUserName As String
        Dim struserPass As String
        Dim LoginLount As Int32

        strUserName = txtUser.Text
        struserPass = txtPassword.Text

        LoginLount = 0

        If (strUserName = "Nash" And struserPass = "Nash") Then 'Chech here if the values mactes from db redired to sucess page
            Response.Redirect("successpage.aspx")
        ElseIf (strUserName <> "Nash" Or struserPass <> "Nash") Then 'if values doesnt match

            hidCount.Value = hidCount.Value + 1
            LoginLount = hidCount.Value
            If (Convert.ToInt32(LoginLount) > 3) Then
                Response.Redirect("Forgotpasspage.aspx")
            Else
                Label1.Text = "Wrong userName or Password"
            End If
        End If

-------------------

Thanks
Nash






Similar Threads
Thread Thread Starter Forum Replies Last Post
datareader MunishBhatia ASP.NET 2.0 Professional 2 October 17th, 2007 07:05 AM
regarding datareader adityamadisetty VB.NET 1 May 8th, 2006 09:31 AM
DataReader truongnnhat ASP.NET 1.0 and 1.1 Basics 2 February 18th, 2005 12:41 AM
DataReader cjcd BOOK: Beginning ASP.NET 1.0 2 March 21st, 2004 01:06 PM
Using DataReader() aadz5 ASP.NET 1.0 and 1.1 Basics 12 November 21st, 2003 06:32 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.