Solved

LOGIN FORM

Posted on 2013-06-17
5
395 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

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

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

688 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