Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 15th, 2004, 03:35 PM
Registered User
 
Join Date: Nov 2004
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default IF ELSE statements

I'm not very comfortable with ASP, and I'm not sure if IF/ELSE statements can be set up like they are in my code. I'm hoping someone can explain why I'm getting the Error Type: Microsoft VBScript compilation (0x800A03F6) Expected 'End' /signupe.asp, line 18. Here's my code:

<%@ Language=VBScript %>
<% Response.Buffer = True %>
<HTML>
<SCRIPT RUNAT=Server LANGUAGE=VBScript>
Sub Session_OnStart
  'Make sure that new users start on the correct
  'page of the ASP application.

  startPage = "/Login.asp"
  currentPage = Request.ServerVariables("SCRIPT_NAME")

  'Do a case-insensitive compare, and if they
  'don't match, send the user to the start page.

  If strcomp(currentPage,startPage,1) then
    Response.Redirect(startPage)
  End If
End Sub
</SCRIPT>

<%
Dim SQL
Dim DetailNum
Dim pin
Dim Closed
Dim requested


%>
<HEAD>
<META HTTP-EQUIV="REFRESH" CONTENT="60;URL=logged_out.htm">
<TITLE>Detail Sign Up</TITLE>
</HEAD>

<BODY background="imagefile/Police.gif" Link="blue" Alink="purple" Vlink="red">
<%

Session("count") = Session("count") + 1
If Session("count") < 5 then
    Session("count") = 0
    Session_Onstart
End if%>

<p><img border="0" src="imagefile/APD_Patch.gif" width="116" height="140">

<b>


<% DetailNum=Request.Form("DetailNum") %>
<% pin=Request.Form("PIN") %>
<% Closed=Request.Form("Closed") %>

<% If Closed then
    Response.Write("Sorry, the closing time has passed for this detail.<br><br>Please press the <i>Back</i> button in your browser to continue.<br>Remember to close your browser window when finished!!")

  Else
      SQL="SELECT PIN, DetailNum FROM RequestedDetails WHERE PIN=" & pin & " AND DetailNum='" & DetailNum & "'"

    set conn = server.createobject ("ADODB.Connection")

    conn.open "ot"

    set requested = conn.execute(SQL)

    If requested.bof and requested.eof then
        Response.Write ("You have already signed up for this detail!")
        requested.close
    Else
        SQL="INSERT INTO RequestedDetails (DetailNum, PIN) VALUES (" & DetailNum & ", " & pin & ")"

        set conn = server.createobject ("ADODB.Connection")

        conn.open "OT"

        conn.execute(SQL)

        Response.Write ("You have been successfully placed on the list for this detail.<br><br>Please press the <i>Back</i> button in your browser to continue.<br>Click the <i>Log Out</i> button if you are finished.")
%>
    <form action="Logout.asp" target="_top" method="POST" name="LogOut" Autocomplete="OFF">
    <input type="Submit" value=" Log Out " align="Left">
    </form>
<%
   End If
%>
</b>

</BODY>
</HTML>




Reply With Quote
  #2 (permalink)  
Old November 15th, 2004, 04:23 PM
Friend of Wrox
 
Join Date: Jan 2004
Location: , , USA.
Posts: 303
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You are missing an "End IF", Make sure you use an "End IF" for each IF ELSE statement

IF <expression> THEN
  Rem Your Code Here
END IF


Reply With Quote
  #3 (permalink)  
Old November 15th, 2004, 04:26 PM
Registered User
 
Join Date: Nov 2004
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

the if/then statements are nested. is that allowed in asp? without all the junk it would look like this:

if <expression> then
     'mycode1'
else
     'mycode2'
     if <expression> then
          'mycode3'



Reply With Quote
  #4 (permalink)  
Old November 15th, 2004, 04:27 PM
Registered User
 
Join Date: Nov 2004
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

sorry, accidentally hit submit.
basically:

if

else

  if

  else



Reply With Quote
  #5 (permalink)  
Old November 15th, 2004, 04:30 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , USA.
Posts: 1,111
Thanks: 0
Thanked 3 Times in 3 Posts
Default

<% If Closed then
    Response.Write("Sorry, the closing time has passed for this detail...
   Else
      SQL="SELECT PIN, DetailNum FROM RequestedDetails ...
      set conn = server.createobject ("ADODB.Connection")
      conn.open "ot"
      set requested = conn.execute(SQL)

      If requested.bof and requested.eof then
          Response.Write ("You have already signed up for this detail!")
          requested.close
      Else
          SQL="INSERT INTO RequestedDetails...
          set conn = server.createobject ("ADODB.Connection")
          conn.open "OT"
          conn.execute(SQL)
%>
    <form action="Logout.asp" target="_top" method="POST" name="LogOut" Autocomplete="OFF">
    <input type="Submit" value=" Log Out " align="Left">
    </form>
<% end if
   End If
%>

shahchi1 said you are missing an end if. I highlighted it in red (and removed some of your code to make it easier to read).

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
if statements brainchild Javascript 2 March 1st, 2007 06:08 AM
If Then Statements in XSL deltree XSLT 2 June 6th, 2006 03:02 PM
Openquery statements aven SQL Server 2000 2 January 11th, 2006 01:33 AM
Case Statements cfriedberg SQL Server 2000 1 September 7th, 2005 08:46 PM
If, else if statements Joel JSP Basics 0 March 18th, 2004 06:17 PM



All times are GMT -4. The time now is 09:40 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.