选择CASE语句错误

时间:2011-07-06 15:09:59

标签: vbscript asp-classic

我有一个SELECT CASE语句,我正在努力工作。基本上我想在DBase中查询特定的组号,并用包含文件显示相应的信息。我收到错误,但无法诊断实际导致错误的原因...

我的陈述结构不正确吗?

<% 
            select case session("memGroup")
            case "123456789","987654321"
            'Show forms for Company ABC
        %>

            <!--#include virtual="/members/_includes/formsABC.asp"-->

        <%             
            case "333333333","22222222","111111111" 
            'Show forms for Company DEF
        %>

            <!--#include virtual="/members/_includes/formsDEF.asp"-->

        <%
          end select
        %>
<!--then show forms for everyone else-->

<!--#include virtual="/members/_includes/formsEveryoneElse.asp"-->

1 个答案:

答案 0 :(得分:4)

ASP将首先处理所有包含,所以这不是最好的方法,因为包含昂贵,我会做这样的事情:

<% 
    Select Case Session.Contents("memGroup")
        Case "123456789", "987654321":
            'Show forms for Company ABC
            Server.Execute("/members/_includes/formsABC.asp")
        Case "333333333", "22222222", "111111111":
            'Show forms for Company DEF
            Server.Execute("/members/_includes/formsDEF.asp")
        Case Else:
            Server.Execute("/members/_includes/formsEveryoneElse.asp")
    End Select
%>

http://msdn.microsoft.com/en-us/library/ms525849(v=vs.90).aspx http://www.4guysfromrolla.com/webtech/022504-1.shtml

另请注意,如果Web服务器运行的是IIS 7或更高版本,则需要更改web.config以查看ASP错误消息:

<configuration>
   <system.webServer>
      <asp scriptErrorSentToBrowser="true"/>
      <httpErrors errorMode="Detailed"/> 
   </system.webServer>
</configuration>

此外,您需要在Internet Explorer中关闭“显示友好HTTP错误消息”或使用其他浏览器查看错误。

http://classicasp.aspfaq.com/general/why-do-i-get-a-500-internal-server-error-for-all-asp-errors.html