?
Solved

LOGIN FORM

Posted on 2013-06-17
5
Medium Priority
?
398 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 1000 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

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

777 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