How do correct the exception occurred?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • shivasusan
    New Member
    • Oct 2008
    • 67

    How do correct the exception occurred?

    Hi!

    I got error. Pls check my error.

    Code:
    <%
    dim uname
    dim pwd
    
    uname = Request.Form("txtuname")
    pwd = Request.Form("txtpwd")
    Session.Contents("uname") = uname
    
    Set rs = Server.CreateObject("ADODB.Recordset")
    Set rs.ActiveConnection = my_Conn
    rs.Open "select * from tbl_Login_info where User_name = '"&uname&"' "
    
    if rs.RecordCount = 0 then
    	rs.Close
    	my_Conn.Close
    	set rs=nothing
    	set my_Conn=nothing
    	Response.Redirect("verify.asp?Submit=namefailed")
    end if
    
    if rs("User_name") = uname  then // [b] i got error in this line "Exception occurred? [b]
    	if rs("Password")= pwd then
    	rs.Close
    	my_Conn.Close
    	set rs=nothing
    	set my_Conn=nothing
    	Response.Redirect("wel.html")
    	else
    	rs.Close
    	my_Conn.Close
    	set rs=nothing
    	set my_Conn=nothing
    	Response.Redirect("verify.asp?Submit=passfailed")
    	end if
    else
    	rs.Close
    	my_Conn.Close
    	set rs=nothing
    	set my_Conn=nothing
    	Response.Redirect("verify.asp?Submit=namefailed")
    end if
    
    %>
  • Soniad
    New Member
    • Jan 2009
    • 66

    #2
    Hi,

    In VbScript we use " ' " to comment code. "//" is used in JavaScript.
    And Avoid writing same code multiple times if it can be written once.
    When you fetch the record, always check EOF or BOF.

    Try the following and reply whether it works :

    Code:
    <% 
    dim uname 
    dim pwd,StrRedirect 
      
    StrRedirect = "verify.asp?Submit=namefailed"	 ' Default Redirect
    
    uname = Trim(Request.Form("txtuname"))
    pwd = Trim(Request.Form("txtpwd")) 
    Session.Contents("uname") = uname 
      
    Set rs = Server.CreateObject("ADODB.Recordset") 
    Set rs.ActiveConnection = my_Conn 
    rs.Open "select * from tbl_Login_info where User_name = '"&uname&"' " 
      
    
    If Not rs.EOF Then
    	If rs("User_name") = uname  Then ' [b] i got error in this line "Exception occurred? [b] 
    		If rs("Password")= pwd Then 
    		StrRedirect = "wel.html"
    		Else 
    		StrRedirect = "verify.asp?Submit=passfailed"	
    		End If
    	End If	
    End If 
      
      
        If rs.State = 1 Then rs.Close
        Set rs=Nothing 
        Set my_Conn=Nothing  
    	
    	Response.Redirect(StrRedirect) 
    %>
    Regards,

    "D"

    Comment

    • shivasusan
      New Member
      • Oct 2008
      • 67

      #3
      Hi,

      Thank you soo much

      Comment

      Working...