Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

LOGIN FORM

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
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…
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…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

618 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