Login Problem ::

Discussion in 'ASP .Net' started by XD, Jul 29, 2006.

  1. XD

    XD Guest

    It is nor redirecting to default.aspx...What I am doing wrong??


    Dim StrUser As String, StrPass As String
    Dim BValid As Boolean
    Dim Conn As Data.SqlClient.SqlConnection
    Dim strCommand As Data.SqlClient.SqlCommand
    Dim strReader As Data.SqlClient.SqlDataReader
    Dim StrSQL As String

    StrUser = txtUser.Text
    StrPass = txtPass.Text

    BValid = False

    Conn = New Data.SqlClient.SqlConnection("Data Source=xxxx; Initial
    Catalog=xxxx; User ID=xxx; Password=xxxx")

    StrSQL = "SELECT * FROM Users WHERE UserName='" & StrUser & "' and
    password='" & StrPass & "'"
    strCommand = New Data.SqlClient.SqlCommand(StrSQL, Conn)
    Conn.Open()

    Response.Write(StrSQL)


    strReader = strCommand.ExecuteReader()

    While strReader.Read()
    If strReader("UserName") <> "" And strReader("Password") <> ""
    Then
    'Response.Cookies("ValidUser").Value = strReader("UserName")
    'Response.Cookies("ValidUser").Expires =
    DateTime.Now.AddMonths(1)
    BValid = True
    Else
    BValid = False
    End If
    End While


    If BValid = True Then
    Response.Redirect("default.aspx")
    ElseIf BValid = False Then
    LblError.Text = "Login Error: Please try again."
    End If

    Conn.Close()
    XD, Jul 29, 2006
    #1
    1. Advertising

  2. XD

    XD Guest

    I got it..
    Thanks

    "XD" <> wrote in message
    news:...
    > It is nor redirecting to default.aspx...What I am doing wrong??
    >
    >
    > Dim StrUser As String, StrPass As String
    > Dim BValid As Boolean
    > Dim Conn As Data.SqlClient.SqlConnection
    > Dim strCommand As Data.SqlClient.SqlCommand
    > Dim strReader As Data.SqlClient.SqlDataReader
    > Dim StrSQL As String
    >
    > StrUser = txtUser.Text
    > StrPass = txtPass.Text
    >
    > BValid = False
    >
    > Conn = New Data.SqlClient.SqlConnection("Data Source=xxxx; Initial
    > Catalog=xxxx; User ID=xxx; Password=xxxx")
    >
    > StrSQL = "SELECT * FROM Users WHERE UserName='" & StrUser & "' and
    > password='" & StrPass & "'"
    > strCommand = New Data.SqlClient.SqlCommand(StrSQL, Conn)
    > Conn.Open()
    >
    > Response.Write(StrSQL)
    >
    >
    > strReader = strCommand.ExecuteReader()
    >
    > While strReader.Read()
    > If strReader("UserName") <> "" And strReader("Password") <> ""
    > Then
    > 'Response.Cookies("ValidUser").Value =
    > strReader("UserName")
    > 'Response.Cookies("ValidUser").Expires =
    > DateTime.Now.AddMonths(1)
    > BValid = True
    > Else
    > BValid = False
    > End If
    > End While
    >
    >
    > If BValid = True Then
    > Response.Redirect("default.aspx")
    > ElseIf BValid = False Then
    > LblError.Text = "Login Error: Please try again."
    > End If
    >
    > Conn.Close()
    >
    XD, Jul 29, 2006
    #2
    1. Advertising

  3. That's good, but it's polite to explain the fix in case someone else with
    the same problem does a search on the issue.

    "XD" <> wrote in message
    news:...
    >I got it..
    > Thanks
    >
    > "XD" <> wrote in message
    > news:...
    >> It is nor redirecting to default.aspx...What I am doing wrong??
    >>
    >>
    >> Dim StrUser As String, StrPass As String
    >> Dim BValid As Boolean
    >> Dim Conn As Data.SqlClient.SqlConnection
    >> Dim strCommand As Data.SqlClient.SqlCommand
    >> Dim strReader As Data.SqlClient.SqlDataReader
    >> Dim StrSQL As String
    >>
    >> StrUser = txtUser.Text
    >> StrPass = txtPass.Text
    >>
    >> BValid = False
    >>
    >> Conn = New Data.SqlClient.SqlConnection("Data Source=xxxx; Initial
    >> Catalog=xxxx; User ID=xxx; Password=xxxx")
    >>
    >> StrSQL = "SELECT * FROM Users WHERE UserName='" & StrUser & "' and
    >> password='" & StrPass & "'"
    >> strCommand = New Data.SqlClient.SqlCommand(StrSQL, Conn)
    >> Conn.Open()
    >>
    >> Response.Write(StrSQL)
    >>
    >>
    >> strReader = strCommand.ExecuteReader()
    >>
    >> While strReader.Read()
    >> If strReader("UserName") <> "" And strReader("Password") <> ""
    >> Then
    >> 'Response.Cookies("ValidUser").Value =
    >> strReader("UserName")
    >> 'Response.Cookies("ValidUser").Expires =
    >> DateTime.Now.AddMonths(1)
    >> BValid = True
    >> Else
    >> BValid = False
    >> End If
    >> End While
    >>
    >>
    >> If BValid = True Then
    >> Response.Redirect("default.aspx")
    >> ElseIf BValid = False Then
    >> LblError.Text = "Login Error: Please try again."
    >> End If
    >>
    >> Conn.Close()
    >>

    >
    >
    Ken Cox [Microsoft MVP], Jul 30, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. William F. Robertson, Jr.
    Replies:
    0
    Views:
    430
    William F. Robertson, Jr.
    Jul 2, 2003
  2. Hermit Dave

    Forms Login Page Not Login Out

    Hermit Dave, Jan 12, 2004, in forum: ASP .Net
    Replies:
    5
    Views:
    456
    Hermit Dave
    Jan 13, 2004
  3. Nans
    Replies:
    2
    Views:
    20,073
    Martin Marinov
    Jun 17, 2004
  4. Pascal Blanchard
    Replies:
    0
    Views:
    239
    Pascal Blanchard
    Aug 17, 2004
  5. Pascal Blanchard
    Replies:
    1
    Views:
    272
    Pascal Blanchard
    Aug 18, 2004
Loading...

Share This Page