Click here to Skip to main content
15,910,303 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
VB
    Dim reader As SqlDataReader
    Dim id As String = Me.loginid.Text
    Dim pass As String = Me.password.Text
    Dim st As String = ConfigurationManager.ConnectionStrings("contructionConnectionStringlap").ToString
    Dim con As New Data.SqlClient.SqlConnection(st)

    Dim q As String = "select *  from login where login_id = '" & id & "' and password = '" & pass & "' "
    Dim com As New Data.SqlClient.SqlCommand(q, con)
    con.Open()
    reader = com.ExecuteReader()

    If reader.HasRows Then
        reader.Read()
                 Dim role As String = (reader("role")).ToString()

        If role = "Admin" Then
            Response.Redirect("welcomeemployee.aspx")
        End If


    Else
        If MsgBox("Incorrect Password Or UserID", MsgBoxStyle.RetryCancel, "Warning") = MsgBoxResult.Cancel Then
            password.Text = ""
            loginid.Text = ""
        End If
    End If


        reader.Close()
        con.Close()
End Sub
Posted
Updated 25-Mar-11 2:25am
v5

That's a shame. Perhaps you should check you input data. Obviously you are not getting what you expect returned from your query.

The information you have given here doesn't provide any indication whatsoever as to what your issue is.
 
Share this answer
 
Comments
adilmemon 24-Mar-11 15:09pm    
after reader reads data it should redirect the page if role = "admin" but it is not redirecting
it is my issue
fjdiewornncalwe 24-Mar-11 15:33pm    
Are you sure that you are even hitting that line of code? Debug your application and set a breakpoint on that line. If you don't hit that line, then your input or data are incorrect.
adilmemon 25-Mar-11 14:56pm    
thanx a lot
after setting break point i got that role has value Admin but wid spaces as
so i use trim(role)
and i got it thanx thanx thanx
thanx a lot
adilmemon 25-Mar-11 6:53am    
AREY IT IS RUNNING NO ERRORS IN IT
OK BUT AFTER READING VALUE OF ROLE IN VARIABLE ROLE
IT IS NOT REDIRECTING AND AT THAT ALSO IT IS NOT SHOWING ERROR BUT IT IS NOT REDIRECTING PAGE
AND WHEN I WRITE VALUE OF ROLE BY USING
RESPONSE.WRITE(ROLE)
IT IS SHOWING ON PAGE ADMIN
BUT IT IS NOT REDIRECT THAT PAGE
Manfred Rudolf Bihy 25-Mar-11 8:23am    
Don't scream around here. Rewrite this with proper capitalization.
dude, check the value you are getting in the role variable. I think this is a classic case of a ordinary typo.
 
Share this answer
 
Comments
adilmemon 25-Mar-11 14:08pm    
i have checked wid response.write(role) command it has value as Admin only but it is not redirecting
You do realize you cannot use this within a webpage unless you build your own right?

VB
If MsgBox("Incorrect Password Or UserID", MsgBoxStyle.RetryCancel, "Warning") = MsgBoxResult.Cancel Then
    password.Text = ""
    loginid.Text = ""
End If
 
Share this answer
 
Comments
Dylan Morley 25-Mar-11 12:22pm    
Yeah was about to point that out!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900