Solved

LOGIN FORM

Posted on 2013-06-17
5
388 Views
Last Modified: 2013-06-21
I am creating a login form simply with a sql datasource.

I have a login page with username textbox, password textbox, and a submit button.
The form also contains the sql datasource

SELECT COUNT(*) AS COUNTOFINFO FROM SOFTECH.TBL_OTUSERS WHERE (USERNAME = :txtUserId) AND ("PASSWORD" = :txtPwd)

The results of this is binded to a listbox.

The code-behind of my login form contains

 Dim Count As Integer

        If (Count > 0) Then
            Response.Redirect("~monthly.aspx")
        ElseIf (Count = 0) Then
            MsgBox("Incorrect userid and password. Please try again!")
            'Return

        End If

However, only the message box is displayed when I click the submit button and the credentials are entered correctly.

Please help
0
Comment
Question by:ernie_shah
5 Comments
 
LVL 18

Expert Comment

by:Jerry Miller
ID: 39254528
Have you put in a break point on the select statement to see what variable values are being passed and checked on the count value? My guess is the variables are not what you expect and it is causing the query to return nothing.
0
 
LVL 10

Expert Comment

by:Monica P
ID: 39255655
1) Initially check this query username and password value and check the count...

SELECT COUNT(*) AS COUNTOFINFO FROM SOFTECH.TBL_OTUSERS WHERE (USERNAME = :txtUserId) AND ("PASSWORD" = :txtPwd)


2) then in the code you have read the count values from "COUNTOFINFO " name and check the Count is > 0  or not...
0
 

Author Comment

by:ernie_shah
ID: 39257414
My sqlquery datasource is generating the correct result.
I modified my query somewhat but still no luck
I am passing the result of my query to a combobox and then to a textbox
I know this doesn't make sense but I was trying all different things to get this to work

My button click code behind is not working though

Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As EventArgs)

        TextBox1.Text = lbCount.SelectedValue
        If TextBox1.Text > 0 Then
            Response.Redirect("MainMenu.aspx")


        Else : TextBox1.Text = 0
            MsgBox("Incorrect userid and password. Please try again!")
            Return
        End If


    End Sub

All I want is the if the username and password combination exists on the system, the login page should redirect to the main menu and if not, an error should appear
0
 
LVL 18

Expert Comment

by:Jerry Miller
ID: 39260638
My button click code behind is not working though

What is not working?

What is the value of lbCount.SelectedValue as you step through the code?

In this code, where are you assigning a value to Count?
Dim Count As Integer

        If (Count > 0) Then
            Response.Redirect("~monthly.aspx")
        ElseIf (Count = 0) Then
            MsgBox("Incorrect userid and password. Please try again!")
            'Return

        End If
0
 
LVL 41

Accepted Solution

by:
guru_sami earned 500 total points
ID: 39260935
May be your button click is not hooked up to the handler. Update your handler definition like:

Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnSubmit.Click

Moreover I think you might want to look more into using asp.net forms authentication.
Check these articles:
http://www.codedigest.com/Articles/ASPNET/112_Implementing_Forms_Authentication_in_ASPNet_20.aspx

http://www.asp.net/web-forms/tutorials/security/introduction/an-overview-of-forms-authentication-vb
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now