Link to home
Start Free TrialLog in
Avatar of Dilys
Dilys

asked on

(0x80020009) Exception occurred

Hi there please i need help !!!!

When a request has been added to my site an email is generated to me and the supervisors.The email has a link to the website.Now the issue here is that I keep getting the error message
Error Type:
(0x80020009)
Exception occurred.
/tasksite/version1/COMMON/asp/allHP.asp, line 13

line 13 is" IF  RSLogin("user_id") <> Session("user_id")  Then  

Below is the code.

<%@ Language=VBScript %>
<!-- #INCLUDE VIRTUAL ="taskSite/version1/inc/connstring.asp"-->
<!-- #INCLUDE VIRTUAL ="taskSite/version1/inc/ADOVBS.INC"-->
<%


       sql = "select user_Id, user_type "
     sql =sql & "from tbl_users "
     sql = sql & "WHERE  user_id ='" & Session("user_id") & "'"
     set RSLogin = conn.execute (sql)
     
     IF  RSLogin("user_id") <> Session("user_id")  Then  
          Response.redirect "http://help/Requestsite/INDEX.asp"
     else
     'Response.write(sql)
 
           if RSLogin("user_type") = "1" then
                    Response.Redirect "../../admin/asp/adminhome.asp"
               elseif RSLogin("user_type") = "2" then
                    Response.Redirect "../../SYSTEMS/asp/sysHome.asp"
               elseif RSLogin("user_type") = "3" then
                    Response.Redirect "../../SUPERVSR/asp/homeS.asp"
               elseif RSLogin("user_type") = "4" then
                    Response.Redirect "../../user/asp/Uhome.asp"
               else
                    Response.Redirect "http://help/Requestsite/INDEX.asp"
          end if
     end if
     
     
     %>

Thanks!!!!
Avatar of MaxOvrdrv2
MaxOvrdrv2

TheID=CInt(Session("user_id")

if RSLogin("user_id")<>TheId then


MaxOvrdrv2
Avatar of Dilys

ASKER

Hi MaxOvrdv2
The code above did not work still getting the error
(0x80020009)
Exception occurred.
/tasksite/version1/COMMON/asp/allHP.asp, line 16

Avatar of fritz_the_blank
Hmmn,

Microsofts knowledgebase does not have an explanation for this error that has anything do with what you have here.

What happens if you do this:

Response.write(RSLogin("user_id"))

Response.write(Session("user_id"))

Fritz the Blank
ok... try this instead then...

if RSLogin.RecordCount<=0 then
      Response.redirect "http://help/Requestsite/INDEX.asp"
else
      rest fo the code
end if


you see... you are telling the Recordset to select from tblUsers WHERE user_id = Session("user_id").... therefore.. the recordset will be empty if the session id is not the same...

also... what type is user_id in the database??

if it is Interger/Numeric type... then there is no need for the extra commans after the = sign:

sql = sql & "WHERE  user_id =" & Session("user_id")

Let me know...

MaxOvrdrv2
Avatar of Dilys

ASKER

Hi Fritz
When i run your code

The userid is returned twice

IDHIDH %>
Avatar of Dilys

ASKER

Hi MaxOvrdrv2,

When i run your code it takes every request to the logging page and this should not be so. becasue when we have a session userid it should take the user to their welcome oage.

NOw the userid is a char field 3
I am using MSSQL 2000 DB

I think the RecordCount may have to do with it?

Thanks
Okay, so we know that you are getting both values the way that you expect. I also see from your code that you wrote out the SQL statement and I trust that gave you what you expected. What is this about the RecordCount? I don't see it in your code...

Fritz the Blank
Avatar of Dilys

ASKER

Hi MaxOvrdrv2,

When i run your code it takes every request to the logging page and this should not be so. becasue when we have a session userid it should take the user to their welcome oage.

NOw the userid is a char field 3
I am using MSSQL 2000 DB

I think the RecordCount may have to do with it?

Thanks
Avatar of Dilys

ASKER

Fritz
when i use the recordcount function  but  it takes everyone to the login page. This should not be so if we have a session for the user. ie if the user is already logged in it should take the user to thier default welcome page.
Avatar of Dilys

ASKER

Fritz
when i use the recordcount function  but  it takes everyone to the login page. This should not be so if we have a session for the user. ie if the user is already logged in it should take the user to thier default welcome page.
But I don't see RecordCount in your code anywhere...

Fritz the Blank
How about change the code to
IF  CStr(RSLogin("user_id")) <> CStr(Session("user_id"))  Then  
Avatar of Dilys

ASKER

Hi Fritz,
MaxOvrdrv2 told me to use it in one of his postings so i did however it now takes all everyone to the login in page.

Well below is the code revised with the recordcount method

<%@ Language=VBScript %>
<!-- #INCLUDE VIRTUAL ="taskSite/version1/inc/connstring.asp"-->
<!-- #INCLUDE VIRTUAL ="taskSite/version1/inc/ADOVBS.INC"-->
<%

       sql = "select user_Id, user_type "
     sql =sql & "from tbl_users "
     sql = sql & "WHERE  user_id ='" & Session("user_id") & "'"
     set RSLogin = conn.execute (sql)
     'Response.write(RSLogin("user_id"))
     'Response.write(Session("user_id"))

     
           if RSLogin.RecordCount<=0 then
                     Response.redirect "http://som-wen2/tasksite/version1/INDEX.asp"
                elseif RSLogin("user_type") = "1" then
                     Response.Redirect "../../admin/asp/adminhome.asp"
                elseif RSLogin("user_type") = "2" then
                     Response.Redirect "../../SYSTEMS/asp/sysHome.asp"
                elseif RSLogin("user_type") = "3" then
                     Response.Redirect "../../SUPERVSR/asp/homeS.asp"
                elseif RSLogin("user_type") = "4" then
                     Response.Redirect "../../user/asp/Uhome.asp"
                else
                     Response.Redirect "../../user/asp/Uhome.asp"
           end if
     
     
     %>

     
     
     

     
I am sorry, I didn't see that.

What if you do this instead?
if Cint(RSLogin("user_type")) > 0 then
     if RSLogin("user_type") = "1" then
          Response.Redirect "../../admin/asp/adminhome.asp"
     elseif RSLogin("user_type") = "2" then
          Response.Redirect "../../SYSTEMS/asp/sysHome.asp"
     elseif RSLogin("user_type") = "3" then
          Response.Redirect "../../SUPERVSR/asp/homeS.asp"
     elseif RSLogin("user_type") = "4" then
          Response.Redirect "../../user/asp/Uhome.asp"
     else
          Response.Redirect "../../user/asp/Uhome.asp"
      end if
else
     Response.redirect "http://som-wen2/tasksite/version1/INDEX.asp"
end if
   
Fritz the Blank
make sure that you are setting the Session variable in the login script...

if you are getting this (everyone gets re-directed) then that means that the session that is being set in the login never matches the one in the database...

MaxOvrdrv2
and also... there is something wrong with the way you are using it... if you base yourself on this:

IF  RSLogin("user_id") <> Session("user_id")  Then  
         Response.redirect "http://help/Requestsite/INDEX.asp"
    else
    'Response.write(sql)

          if RSLogin("user_type") = "1" then
                   Response.Redirect "../../admin/asp/adminhome.asp"
              elseif RSLogin("user_type") = "2" then
                   Response.Redirect "../../SYSTEMS/asp/sysHome.asp"
              elseif RSLogin("user_type") = "3" then
                   Response.Redirect "../../SUPERVSR/asp/homeS.asp"
              elseif RSLogin("user_type") = "4" then
                   Response.Redirect "../../user/asp/Uhome.asp"
              else
                   Response.Redirect "http://help/Requestsite/INDEX.asp"
         end if
    end if


then it should look like this:

IF  RSLogin.RecordCount<=0 Then  
         Response.redirect "http://help/Requestsite/INDEX.asp"
else
    'Response.write(sql)

          if RSLogin("user_type") = "1" then
                   Response.Redirect "../../admin/asp/adminhome.asp"
              elseif RSLogin("user_type") = "2" then
                   Response.Redirect "../../SYSTEMS/asp/sysHome.asp"
              elseif RSLogin("user_type") = "3" then
                   Response.Redirect "../../SUPERVSR/asp/homeS.asp"
              elseif RSLogin("user_type") = "4" then
                   Response.Redirect "../../user/asp/Uhome.asp"
              else
                   Response.Redirect "http://help/Requestsite/INDEX.asp"
         end if
    end if

MaxOvrdrv2
Avatar of Dilys

ASKER

Hi Fritz,
MaxOvrdrv2 told me to use it in one of his postings so i did however it now takes all everyone to the login in page.

Well below is the code revised with the recordcount method

<%@ Language=VBScript %>
<!-- #INCLUDE VIRTUAL ="taskSite/version1/inc/connstring.asp"-->
<!-- #INCLUDE VIRTUAL ="taskSite/version1/inc/ADOVBS.INC"-->
<%

       sql = "select user_Id, user_type "
     sql =sql & "from tbl_users "
     sql = sql & "WHERE  user_id ='" & Session("user_id") & "'"
     set RSLogin = conn.execute (sql)
     'Response.write(RSLogin("user_id"))
     'Response.write(Session("user_id"))

     
           if RSLogin.RecordCount<=0 then
                     Response.redirect "http://som-wen2/tasksite/version1/INDEX.asp"
                elseif RSLogin("user_type") = "1" then
                     Response.Redirect "../../admin/asp/adminhome.asp"
                elseif RSLogin("user_type") = "2" then
                     Response.Redirect "../../SYSTEMS/asp/sysHome.asp"
                elseif RSLogin("user_type") = "3" then
                     Response.Redirect "../../SUPERVSR/asp/homeS.asp"
                elseif RSLogin("user_type") = "4" then
                     Response.Redirect "../../user/asp/Uhome.asp"
                else
                     Response.Redirect "../../user/asp/Uhome.asp"
           end if
     
     
     %>

     
     
     

     
Avatar of Dilys

ASKER

Hi all,
I have tried everything you have written and its not working.As I said before the record count function returns every user to the logging in page.
I have verified that the userid and user-type are being generated. so I do not know what is going on.

Please help!!!!
have you tried my latest post?

MaxOvrdrv2
Avatar of Dilys

ASKER

Hi MaxOvdrv2
I tried it

but i got the error below
(0x80020009)
Exception occurred.
/tasksite/version1/COMMON/asp/allHP.asp, line 16

line 16 is
IF  RSLogin("user_id") <> Session("user_id")  Then

I wonder if the problem isn't the line:

        Response.redirect "http://help/Requestsite/INDEX.asp"


rather than:

IF  RSLogin("user_id") <> Session("user_id")  Then  

What if you put this at the top of your page:

<%@ Language = VBScript %>
<%Response.Buffer = True%>


I know that there can be problems with the redirect if you don't have buffering enabled.

Fritz the Blank
Avatar of Dilys

ASKER

I placed
<%Response.Buffer = True%>
well back to square 1 takes me to the loging page and not the specifeid user pages.

Okay, well that is progess, because at least we found out what was causing your error. So, the good news--we know the answer to your original question, the bad news--we have a new question about why your code doesn't work as expected....

Fritz the Blank
What happens if you use your original code but with the buffering enabled?

Fritz the Blank
I am also wondering about this line:

 IF  RSLogin("user_id") <> Session("user_id")  Then  


Have you tried isolating this to make sure that it works? You might also try this instead:

If strComp(RSLogin("user_id"),Session("user_id"),1) = 0 then

that will compare the two strings regardless of case. If you want to make a distinction between upper and lower case, use:

If strComp(RSLogin("user_id"),Session("user_id"),0) = 0 then


Fritz the Blank
SOLUTION
Avatar of MaxOvrdrv2
MaxOvrdrv2

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
And it would still be helpful to enable the buffering no matter what you do.

Fritz the Blank
Avatar of Dilys

ASKER

Thanks Everyone for your help.
I figured it out by

Checking to see if userid is blank then redirect to login page

IF Session("user_id") = "" then
     Response.redirect "http://help/INDEX.asp"
     Else
sql statement
select *
where session userid = userid
then code to display pages based on user_type.
If rslogin ..........

Well thanks everyone for your help !!!!!!
     
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I am happy that a solution has been reached. Be sure to close this question out,

Fritz the Blank
good thinking... see.. you're better than us... ;-) lol!

MaxOvrdrv2
MaxOvrdrv2,

That's not what I meant!!!

I just wanted to ask why we didn't get that way earlier when I asked.

BTW, I left the information about split() and join() in the other post.

Fritz the Blank
no no frits.. my last post was not meant for you... :) i meant: see Dilys... you're better than us! :)

and yes... thanks for the split join info... very useful and helpful... thank you very much! :)

MaxOvrdrv2
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Split Points - fritz_the_blank / MaxOvrdrv2

Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
GaryC123
EE Cleanup Volunteer