ASP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreASP Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 5th, 2003, 04:05 AM
kk5st's Avatar
kk5st kk5st is offline
Thanks Johnny Hart (BC) R.I.P.
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: May 2003
Location: Dallas
Posts: 4,589 kk5st User rank is Brigadier General (60000 - 70000 Reputation Level)kk5st User rank is Brigadier General (60000 - 70000 Reputation Level)kk5st User rank is Brigadier General (60000 - 70000 Reputation Level)kk5st User rank is Brigadier General (60000 - 70000 Reputation Level)kk5st User rank is Brigadier General (60000 - 70000 Reputation Level)kk5st User rank is Brigadier General (60000 - 70000 Reputation Level)kk5st User rank is Brigadier General (60000 - 70000 Reputation Level)kk5st User rank is Brigadier General (60000 - 70000 Reputation Level)kk5st User rank is Brigadier General (60000 - 70000 Reputation Level)kk5st User rank is Brigadier General (60000 - 70000 Reputation Level)kk5st User rank is Brigadier General (60000 - 70000 Reputation Level)kk5st User rank is Brigadier General (60000 - 70000 Reputation Level)kk5st User rank is Brigadier General (60000 - 70000 Reputation Level) 
Time spent in forums: 1 Month 2 Days 17 h 41 m 9 sec
Reputation Power: 662
CASE statements and passing arguments

I've been asked to help with some asp pages. Naturally I am like Sgt Schultz when it comes to vbscript or asp--"I know nothing."

I have a login page that calls another script based on the usertype. The login script sets a variable Session("User_Type"), does some cleanup, then redirects (correctly). So far, so good--I think.

The second script validates the user before opening the page. It uses the variable Session("User_Type") in a case statement. The default is an error message.

The following is the error message on opening the second page.

Code:
Microsoft VBScript compilation  error '800a0400'

Expected statement

/library/library.asp, line 7

select case Session("User_Type")
		case "Admin", "FBR Employee", "Agent"
----------------------------------^

I suspect it is due to no statement in the matched case. I was looking for a break statement to kick out to the page HTML. Here is the library.asp code.
Code:
<%@ Language = "VBScript" %>
<%
 	Option Explicit
 	'On Error Resume Next
  	Response.Expires = 0
 	select case Session("User_Type")
'how does script get variable?
		case "Admin", "FBR Employee", "Agent"
 			'It is ok for this user to proceed and view this page
'shouldn't there be a statement here?
 		case else
			'Error trap
 			%>
            <html>
            <head><title>Invalid Form Library Access</title>
            </head>
            <body>
<!-- error page html -->
            </body>
            </html>
            <%
 			Response.End
	end select
 %>

<html>
<head>
<!-- regular page html -->

I don't see how Session("User_Type") gets sent to the script either. Just in case it will help, here is a snippet of login code.
Code:
                case "FBR Employee", "Agent"
                   'Set the session variable that will be needed to grant access to the admin
                   'and form library pages
                   Session("User_Type") = rsLogin("User_Type")
                   'Set the insert statement for this login attempt
                   if sqlInsertLogin <> "" then
                       conFBRWebDB.Execute(sqlInsertLogin)
                   end if
                   
                   ' Clean up before the redirect
                   rsLogin.Close
                   Set rsLogin = Nothing
                   conFBRWebDB.Close
                   Set conFBRWebDB = Nothing
                   Response.Redirect("library/library.asp")

I will certainly appreciate any help here.

cheers,

gary
__________________
There are those who manage to build a web site without knowing what they're doing; thereby proving to themselves they do, indeed, know what they're doing.

My html and css workshop, demos and tutorials.
Ask a better question, get a better answer.

Reply With Quote
  #2  
Old October 5th, 2003, 02:30 PM
kkong's Avatar
kkong kkong is offline
Monkey Magic
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Location: UK
Posts: 103 kkong User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to kkong
Hi,

what does FBR Employee and Agent do? Are you trying to set these as variables?


Kong.

Reply With Quote
  #3  
Old October 5th, 2003, 10:47 PM
kk5st's Avatar
kk5st kk5st is offline
Thanks Johnny Hart (BC) R.I.P.
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: May 2003
Location: Dallas
Posts: 4,589 kk5st User rank is Brigadier General (60000 - 70000 Reputation Level)kk5st User rank is Brigadier General (60000 - 70000 Reputation Level)kk5st User rank is Brigadier General (60000 - 70000 Reputation Level)kk5st User rank is Brigadier General (60000 - 70000 Reputation Level)kk5st User rank is Brigadier General (60000 - 70000 Reputation Level)kk5st User rank is Brigadier General (60000 - 70000 Reputation Level)kk5st User rank is Brigadier General (60000 - 70000 Reputation Level)kk5st User rank is Brigadier General (60000 - 70000 Reputation Level)kk5st User rank is Brigadier General (60000 - 70000 Reputation Level)kk5st User rank is Brigadier General (60000 - 70000 Reputation Level)kk5st User rank is Brigadier General (60000 - 70000 Reputation Level)kk5st User rank is Brigadier General (60000 - 70000 Reputation Level)kk5st User rank is Brigadier General (60000 - 70000 Reputation Level) 
Time spent in forums: 1 Month 2 Days 17 h 41 m 9 sec
Reputation Power: 662
Quote:
Originally posted by kkong
what does FBR Employee and Agent do? Are you trying to set these as variables?

In the login script, these are possible values of rsLogin, the result of a db query. It is the tested value in the case statement.

In the function block, this value is assigned to Session("User_Type"), which is the tested variable in the second script, library.asp.

cheers,

gary

Reply With Quote
  #4  
Old October 6th, 2003, 02:38 AM
kkong's Avatar
kkong kkong is offline
Monkey Magic
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Location: UK
Posts: 103 kkong User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to kkong
Hi,

At the end of your case statment you don't have an action.

ie your looking for three different names but your not finishing that particular line of the case.

as a test you could try setting a dummy variable at the end to see if that works.

ie:

Code:

case "Admin", "FBR Employee", "Agent" Anyvariable=1


Kong.

Reply With Quote
  #5  
Old October 6th, 2003, 04:29 AM
kk5st's Avatar
kk5st kk5st is offline
Thanks Johnny Hart (BC) R.I.P.
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: May 2003
Location: Dallas
Posts: 4,589 kk5st User rank is Brigadier General (60000 - 70000 Reputation Level)kk5st User rank is Brigadier General (60000 - 70000 Reputation Level)kk5st User rank is Brigadier General (60000 - 70000 Reputation Level)kk5st User rank is Brigadier General (60000 - 70000 Reputation Level)kk5st User rank is Brigadier General (60000 - 70000 Reputation Level)kk5st User rank is Brigadier General (60000 - 70000 Reputation Level)kk5st User rank is Brigadier General (60000 - 70000 Reputation Level)kk5st User rank is Brigadier General (60000 - 70000 Reputation Level)kk5st User rank is Brigadier General (60000 - 70000 Reputation Level)kk5st User rank is Brigadier General (60000 - 70000 Reputation Level)kk5st User rank is Brigadier General (60000 - 70000 Reputation Level)kk5st User rank is Brigadier General (60000 - 70000 Reputation Level)kk5st User rank is Brigadier General (60000 - 70000 Reputation Level) 
Time spent in forums: 1 Month 2 Days 17 h 41 m 9 sec
Reputation Power: 662
Quote:
At the end of your case statment you don't have an action.

ie your looking for three different names but your not finishing that particular line of the case.

I think I mentioned that.
Quote:
I suspect it is due to no statement in the matched case. I was looking for a break statement to kick out to the page HTML.


What would be the vbs equivalent of a "break" statement? I think what I need to do is simply break out of the case block and drop into the HTML.

Additionally, how is the test variable passed to the second (library.asp) script?

g

Reply With Quote
  #6  
Old October 7th, 2003, 05:26 PM
kk5st's Avatar
kk5st kk5st is offline
Thanks Johnny Hart (BC) R.I.P.
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: May 2003
Location: Dallas
Posts: 4,589 kk5st User rank is Brigadier General (60000 - 70000 Reputation Level)kk5st User rank is Brigadier General (60000 - 70000 Reputation Level)kk5st User rank is Brigadier General (60000 - 70000 Reputation Level)kk5st User rank is Brigadier General (60000 - 70000 Reputation Level)kk5st User rank is Brigadier General (60000 - 70000 Reputation Level)kk5st User rank is Brigadier General (60000 - 70000 Reputation Level)kk5st User rank is Brigadier General (60000 - 70000 Reputation Level)kk5st User rank is Brigadier General (60000 - 70000 Reputation Level)kk5st User rank is Brigadier General (60000 - 70000 Reputation Level)kk5st User rank is Brigadier General (60000 - 70000 Reputation Level)kk5st User rank is Brigadier General (60000 - 70000 Reputation Level)kk5st User rank is Brigadier General (60000 - 70000 Reputation Level)kk5st User rank is Brigadier General (60000 - 70000 Reputation Level) 
Time spent in forums: 1 Month 2 Days 17 h 41 m 9 sec
Reputation Power: 662
Can no one answer this? It looks to me like I need to simply break out of the conditional block and pick up the html that follows.

Unfortunately, I know no vbscript. Would an 'exit' statement exit the script, or just the block? Were this PHP, I would use something like this;
PHP Code:
switch($var)
{
  case 
1:
    break;
  case 
2:
    echo 
"<html>
      ...error message
      </html>
}
<html>
...regular page
</html> 

tnx,

gary

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > CASE statements and passing arguments


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT