Solved

asp execution too slow...

Posted on 2006-07-11
2
319 Views
Last Modified: 2008-02-26
i don't know this page take too much time to execute...
can anyone correct the code so it can load faster....


.......................

<!--#include file="opendb.asp"-->
<%
  Dim strEMail, strPassword
  strUserName = Request.Form("UserName")
  strPassword = Request.Form("Password")

  Dim rsUsers
  set rsUsers = Server.CreateObject("ADODB.Recordset")
  strSQL = "SELECT * FROM Users WHERE FUserName = '" & strUserName & "';"
  rsUsers.Open strSQL, objConn

  If rsUsers.EOF Then                                                         'user not found
    Session("UserName") = Request.Form("UserName")
    If Request.Querystring("SecondTry") = "True" then                    'user's had two goes
      Response.Redirect "join.asp?NotFound=True"                        ' - must register
    Else                                                      'username wrong; password wrong
      Response.Redirect "login.asp?SecondTry=True"                       ' - allow another go
    End If
  Else                                              'one or more users found - check password
    While Not rsUsers.EOF
      If UCase(rsUsers("FPassword")) = UCase(strPassword) Then              'password matched
        Dim strName, strValue
        For Each strField in rsUsers.Fields
          strName = strField.Name                                 'populate session variables
          strValue = strField.value
          Session(strName) = strValue
        Next
        Session("blnValidUser") = True
        If rsUsers("FRemPass") = True Then
          Response.Cookies("PMBVisit")("UserName") = rsUsers("FUserName")
          Response.Cookies("PMBVisit")("NickName") = rsUsers("FNickName")
          Response.Cookies("PMBVisit")("Email") = rsUsers("FEmail")
          Response.Cookies("PMBVisit")("UserID") = rsUsers("FUserID")
        End If
        Response.Redirect "default.asp"                      'successful login
      Else
        rsUsers.MoveNext
      End If
    Wend

    rsUsers.Close
    set rsUsers = Nothing

    objConn.Close
      set objConn = Nothing

    Session("UserName") = Request.Form("UserName")                'if we get this far then...
                                                ' ...password doesn't match any of DB entries
    If Request("SecondTry") = "True" then                                'user's had two goes
      Response.Redirect "register.asp"                                    ' - must reregister
    Else                                                      'username right; password wrong
      Response.Redirect "login.asp?SecondTry=True&WrongPW=True"
                                                                            'allow another go
    End If
  End If

%>
0
Comment
Question by:coolx
2 Comments
 
LVL 50

Accepted Solution

by:
Ryan Chong earned 130 total points
ID: 17079560
A while loop may not necessary here...

try:

....
If rsUsers.EOF Then                                                         'user not found
   Session("UserName") = Request.Form("UserName")
    If Request.Querystring("SecondTry") = "True" then                    'user's had two goes
      Response.Redirect "join.asp?NotFound=True"                        ' - must register
    Else                                                      'username wrong; password wrong
      Response.Redirect "login.asp?SecondTry=True"                       ' - allow another go
    End If
  Else                                              'one or more users found - check password
      If UCase(rsUsers("FPassword")) = UCase(strPassword) And rsUsers("FUserName") = strUserName Then              'password and username matched
        Dim strName, strValue
        For Each strField in rsUsers.Fields
          strName = strField.Name                                 'populate session variables
          strValue = strField.value
          Session(strName) = strValue
        Next
        Session("blnValidUser") = True
        If rsUsers("FRemPass") = True Then
          Response.Cookies("PMBVisit")("UserName") = rsUsers("FUserName")
          Response.Cookies("PMBVisit")("NickName") = rsUsers("FNickName")
          Response.Cookies("PMBVisit")("Email") = rsUsers("FEmail")
          Response.Cookies("PMBVisit")("UserID") = rsUsers("FUserID")
        End If
        Response.Redirect "default.asp"                      'successful login
      Else
        Response.Redirect "login.asp?Invalidlogin=True"
      End If
End if
...
0
 

Author Comment

by:coolx
ID: 17087532
this code is a lot faster... can it be a little faster..........
thanks anyways,

 
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
Developer portfolios can be a bit of an enigma—how do you present yourself to employers without burying them in lines of code?  A modern portfolio is more than just work samples, it’s also a statement of how you work.
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.

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