Solved

LOGIN FORM

Posted on 2013-06-17
5
390 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

832 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