|
 |
access_asp thread: Expected statement - End Sub
Message #1 by "Lori Bannon" <lori@s...> on Fri, 15 Nov 2002 22:46:26
|
|
I've been using a ASP shopping cart tutorial to learn ASP. So far so good
till now'
here's my error...
Expected statement
End Sub
here's my code...
<%
Option Explicit
Sub DrawPage()
%>
<HTML>
<HEAD>
<title><%= pageTitle %></title>
<link rel="stylesheet" type="text/css" href="stylin.css" />
</HEAD>
<!--#include file="../include/body.htm"-->
<table width="760" border="0" cellspacing="0" cellpadding="0">
<!--//top navigation include//-->
<tr>
<td colspan="2" nowrap class="textMain">
<FORM action=DisplayResults.asp method=post>
<table width="760" border="0" cellspacing="0" cellpadding="0">
<tr valign="top">
<td width="180"><img src="http://127.0.0.1/ASPCart/images/main/logo.gif"
width="180" height="80" border="0" alt=""></td>
<td width="580" height="20" bgcolor="#336600"> </td>
</tr>
<tr>
<td width="180" height="20" bgcolor="#336600"> </td>
<td width="580" bgcolor="#339900"
class="textMain"> <a href="index.asp"
class="color">HOME</a> Selec
t a Category:
<%
'Move to the first record in the recordset
rs.MoveFirst
'Draw the select start tag
response.write "<SELECT NAME=selProduct>"
while not rs.EOF
'Draw option for select element
response.write "<OPTION value=" & rs("categoryCode") & ">" & rs
("categoryDescription")
'Move to the next record in recordset
rs.MoveNext
wend
'Complete drawing the Select element
response.write "</select>"
%>
<input type=submit value="View Categories">
</form>
</td>
</tr>
<!--// End of Navigation //-->
</td>
</tr>
</table></td>
</tr>
<tr valign="top">
<!--//left navigation include//--><td width="180" nowrap><!--#include
file="../include/leftNav.htm"--></td>
<!--//end of left nav //-->
<!--// start of middle content //-->
<td>
<br />
<table border="0" width="450" cellspacing="3" cellpadding="3"
align="center">
<tr>
<td colspan="5" class="subHeader">Category: <%= pageTitle %></td>
</tr>
<tr valign="top">
<td width="450" align="center">
<table border="1" text="#FFFFFF">
<tr>
<td class="textMain">Product ID</td>
<td class="textMain">Product Name</td>
<td class="textMain">Category Description</td>
<td class="textMain">Model</td>
<td class="textMain">Price</td>
<td class="textMain">Brief Description</td>
</tr>
<%
'Set the current record pointer to the first record of the recordset
rs.MoveFirst
'Loop through all the records in the recordset
while not rs.EOF
'Load recordset field values into local variables
'Note concatenating a zero-length string on the end of the field
'value automatically converts Null values into zero-length strings!!
'USE THIS APPROACH FROM NOW ON!
ID = rs("productID") & ""
name = rs("productName") & ""
cDesc = rs("categoryDescription") & ""
model = rs("modelName") & ""
price = rs("price") & ""
bDescription = rs("briefDescription") & ""
'Format the sales value, if there is a value for it
'Note: the FormatCurrency function REALLY doesn't like empty strings,
' so from now on be sure and check for them before using
FormatCurrency.
If price <> "" then
price = FormatCurrency(price)
End If
%>
<tr>
<td class="textMain"><%= ID %></td>
<td class="textMain">
<A HREF="DisplayIndividual.asp?qryProdID=<%= ID %>"><%=
name %></td>
<td class="textMain"><%= cDesc %></td>
<td class="textMain"><%= model %></td>
<td class="textMain"><%= price %></td>
<td class="textMain"><%= bDescription %></td>
</tr>
</table>
</td>
</tr>
<tr>
<td><!--#include file="../include/copyright.htm"--></td>
</tr>
</table>
</td>
</tr>
</table>
</BODY>
</HTML>
<%
End Sub
'------------------------------------------------
' END OF PROCEDURES AND START OF MAIN CODE
'------------------------------------------------
dim rs
dim sqlString
dim ID, name, CCode, cDesc, model, price, bDescription
dim connectionString, databaseName, path
dim pageTitle
'Set connection details
'Note: this assumes that the database is in the same folder/directory
'as this asp file
path = Server.MapPath(".")
databaseName = "../data/store.mdb"
'connectionString = "DRIVER={Microsoft Access Driver (*.mdb)};" & _
' "DBQ=" & path & "\" & databaseName & ";"
connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" _
& path & "\" & databaseName
'Get video category code
CCode = Request.Form("selProduct")
'Set sql string
sqlString = "Select * from tblCategories, tblAmplifiers"
sqlString = sqlString & " Where
tblCategories.categoryCode=tblAmplifiers.categoryCode"
If CCode <> "" Then
sqlString = sqlString & " AND tblCategories.categoryCode='" &
CCode & "'"
End If
'Set page title variable
if CCode = "" then
pageTitle = "All Categories"
else
pageTitle = CCode
end if
sqlString = sqlString & " Order By ProductName"
'Debug printing (comment this out for your final version)
'response.write "sqlString = " & sqlString & "<p>"
'Create a recordset
set rs = Server.CreateObject("ADODB.Recordset")
rs.Open sqlString, connectionString
Call DrawPage()
'Close the recordset
rs.Close
Set rs = Nothing
%>
Thanks ahead of time
Lori
Message #2 by "Larry Woods" <larry@l...> on Fri, 15 Nov 2002 16:16:10 -0700
|
|
I have not (can not!) follow your complete page, but I don't
think that you want the Sub in the first place! Calling the
subroutine will NOT generate the HTML, if that is what you are
thinking. As the ASP processor "sees" the HTML it will prep it
for transmission. It will NOT wait for you to call the
subroutine.
Larry Woods
> -----Original Message-----
> From: Lori Bannon [mailto:lori@s...]
> Sent: Friday, November 15, 2002 10:46 PM
> To: Access ASP
> Subject: [access_asp] Expected statement - End Sub
>
>
> I've been using a ASP shopping cart tutorial to learn
> ASP. So far so good
> till now'
>
> here's my error...
>
> Expected statement
> End Sub
>
> here's my code...
>
> <%
> Option Explicit
>
> Sub DrawPage()
> %>
> <HTML>
>
> <HEAD>
> <title><%= pageTitle %></title>
> <link rel="stylesheet" type="text/css" href="stylin.css" />
> </HEAD>
>
> <!--#include file="../include/body.htm"-->
>
> <table width="760" border="0" cellspacing="0" cellpadding="0">
>
> <!--//top navigation include//-->
> <tr>
> <td colspan="2" nowrap class="textMain">
> <FORM action=DisplayResults.asp method=post>
> <table width="760" border="0" cellspacing="0" cellpadding="0">
>
> <tr valign="top">
> <td width="180"><img
> src="http://127.0.0.1/ASPCart/images/main/logo.gif"
> width="180" height="80" border="0" alt=""></td>
> <td width="580" height="20" bgcolor="#336600"> </td>
> </tr>
>
> <tr>
> <td width="180" height="20" bgcolor="#336600"> </td>
> <td width="580" bgcolor="#339900"
> class="textMain"> <a href="index.asp"
> class="color">HOME</a> &nb
> sp; Selec
> t a Category:
>
> <%
> 'Move to the first record in the recordset
> rs.MoveFirst
>
> 'Draw the select start tag
> response.write "<SELECT NAME=selProduct>"
>
> while not rs.EOF
>
> 'Draw option for select element
> response.write "<OPTION value=" &
> rs("categoryCode") & ">" & rs
> ("categoryDescription")
>
> 'Move to the next record in recordset
> rs.MoveNext
>
> wend
>
> 'Complete drawing the Select element
> response.write "</select>"
>
> %>
>
> <input type=submit value="View Categories">
>
> </form>
> </td>
> </tr>
>
>
> <!--// End of Navigation //-->
> </td>
> </tr>
> </table></td>
> </tr>
>
> <tr valign="top">
>
> <!--//left navigation include//--><td width="180"
> nowrap><!--#include
> file="../include/leftNav.htm"--></td>
>
> <!--//end of left nav //-->
>
> <!--// start of middle content //-->
>
> <td>
> <br />
> <table border="0" width="450" cellspacing="3"
> cellpadding="3"
> align="center">
>
> <tr>
> <td colspan="5" class="subHeader">Category: <%
> pageTitle %></td>
> </tr>
>
> <tr valign="top">
> <td width="450" align="center">
> <table border="1" text="#FFFFFF">
> <tr>
> <td class="textMain">Product ID</td>
> <td class="textMain">Product Name</td>
> <td class="textMain">Category Description</td>
> <td class="textMain">Model</td>
> <td class="textMain">Price</td>
> <td class="textMain">Brief Description</td>
> </tr>
>
> <%
> 'Set the current record pointer to the first
> record of the recordset
> rs.MoveFirst
>
> 'Loop through all the records in the recordset
> while not rs.EOF
>
> 'Load recordset field values into local variables
> 'Note concatenating a zero-length string on the
> end of the field
> 'value automatically converts Null values into
> zero-length strings!!
> 'USE THIS APPROACH FROM NOW ON!
>
> ID = rs("productID") & ""
> name = rs("productName") & ""
> cDesc = rs("categoryDescription") & ""
> model = rs("modelName") & ""
> price = rs("price") & ""
> bDescription = rs("briefDescription") & ""
>
>
> 'Format the sales value, if there is a value for it
> 'Note: the FormatCurrency function REALLY
> doesn't like empty strings,
> ' so from now on be sure and check for them before using
> FormatCurrency.
> If price <> "" then
> price = FormatCurrency(price)
> End If
> %>
>
>
> <tr>
> <td class="textMain"><%= ID %></td>
> <td class="textMain">
> <A
> HREF="DisplayIndividual.asp?qryProdID=<%= ID %>"><%
> name %></td>
> <td class="textMain"><%= cDesc %></td>
> <td class="textMain"><%= model %></td>
> <td class="textMain"><%= price %></td>
> <td class="textMain"><%= bDescription %></td>
> </tr>
>
> </table>
>
> </td>
> </tr>
>
> <tr>
> <td><!--#include file="../include/copyright.htm"--></td>
> </tr>
>
> </table>
>
> </td>
> </tr>
>
> </table>
> </BODY>
> </HTML>
> <%
>
> End Sub
>
> '------------------------------------------------
> ' END OF PROCEDURES AND START OF MAIN CODE
> '------------------------------------------------
> dim rs
> dim sqlString
> dim ID, name, CCode, cDesc, model, price,
> bDescription
> dim connectionString, databaseName, path
> dim pageTitle
>
> 'Set connection details
> 'Note: this assumes that the database is in the
> same folder/directory
> 'as this asp file
> path = Server.MapPath(".")
> databaseName = "../data/store.mdb"
> 'connectionString = "DRIVER={Microsoft Access
> Driver (*.mdb)};" & _
> ' "DBQ=" & path & "\" & databaseName & ";"
> connectionString
> "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" _
> & path & "\" & databaseName
>
> 'Get video category code
> CCode = Request.Form("selProduct")
>
> 'Set sql string
> sqlString = "Select * from tblCategories, tblAmplifiers"
> sqlString = sqlString & " Where
> tblCategories.categoryCode=tblAmplifiers.categoryCode"
>
> If CCode <> "" Then
> sqlString = sqlString & " AND
> tblCategories.categoryCode='" &
> CCode & "'"
> End If
>
> 'Set page title variable
> if CCode = "" then
>
> pageTitle = "All Categories"
>
> else
>
> pageTitle = CCode
>
> end if
>
>
> sqlString = sqlString & " Order By ProductName"
>
> 'Debug printing (comment this out for your final version)
> 'response.write "sqlString = " & sqlString & "<p>"
>
> 'Create a recordset
> set rs = Server.CreateObject("ADODB.Recordset")
> rs.Open sqlString, connectionString
>
> Call DrawPage()
>
> 'Close the recordset
> rs.Close
> Set rs = Nothing
>
> %>
>
>
> Thanks ahead of time
> Lori
Message #3 by "Charles Mabbott" <aa8vs@m...> on Fri, 15 Nov 2002 19:02:33 -0500
|
|
Rather than trying to generate the page as a subroutine there is no reason
not to combine the html, asp code in the same page and put the proper HTML
commands in there proper places. It will end up being a much cleaner and
easier to follow page.
Regards,
Chuck
"Whoever said the pen is mightier than the
sword obviously never encountered automatic
weapons."
http://68.43.100.7:81/aa8vs
>From: "Lori Bannon" <lori@s...>
>Reply-To: "Access ASP" <access_asp@p...>
>To: "Access ASP" <access_asp@p...>
>Subject: [access_asp] Expected statement - End Sub
>Date: Fri, 15 Nov 2002 22:46:26
>
>I've been using a ASP shopping cart tutorial to learn ASP. So far so good
>till now'
>
>here's my error...
>
>Expected statement
>End Sub
>
>here's my code...
>
><%
>Option Explicit
>
>Sub DrawPage()
>%>
><HTML>
>
><HEAD>
> <title><%= pageTitle %></title>
> <link rel="stylesheet" type="text/css" href="stylin.css" />
></HEAD>
>
><!--#include file="../include/body.htm"-->
>
><table width="760" border="0" cellspacing="0" cellpadding="0">
>
><!--//top navigation include//-->
> <tr>
> <td colspan="2" nowrap class="textMain">
> <FORM action=DisplayResults.asp method=post>
><table width="760" border="0" cellspacing="0" cellpadding="0">
>
><tr valign="top">
><td width="180"><img src="http://127.0.0.1/ASPCart/images/main/logo.gif"
>width="180" height="80" border="0" alt=""></td>
><td width="580" height="20" bgcolor="#336600"> </td>
></tr>
>
><tr>
><td width="180" height="20" bgcolor="#336600"> </td>
><td width="580" bgcolor="#339900"
>class="textMain"> <a href="index.asp"
>class="color">HOME</a> Selec
>t a Category:
>
><%
> 'Move to the first record in the recordset
> rs.MoveFirst
>
> 'Draw the select start tag
> response.write "<SELECT NAME=selProduct>"
>
> while not rs.EOF
>
> 'Draw option for select element
> response.write "<OPTION value=" & rs("categoryCode") & ">" & rs
>("categoryDescription")
>
> 'Move to the next record in recordset
> rs.MoveNext
>
> wend
>
> 'Complete drawing the Select element
> response.write "</select>"
>
>%>
>
> <input type=submit value="View Categories">
>
></form>
> </td>
></tr>
>
>
><!--// End of Navigation //-->
></td>
></tr>
></table></td>
></tr>
>
><tr valign="top">
>
><!--//left navigation include//--><td width="180" nowrap><!--#include
>file="../include/leftNav.htm"--></td>
>
><!--//end of left nav //-->
>
><!--// start of middle content //-->
>
> <td>
> <br />
> <table border="0" width="450" cellspacing="3" cellpadding="3"
>align="center">
>
> <tr>
> <td colspan="5" class="subHeader">Category: <%= pageTitle %></td>
> </tr>
>
> <tr valign="top">
> <td width="450" align="center">
><table border="1" text="#FFFFFF">
> <tr>
> <td class="textMain">Product ID</td>
> <td class="textMain">Product Name</td>
> <td class="textMain">Category Description</td>
> <td class="textMain">Model</td>
> <td class="textMain">Price</td>
> <td class="textMain">Brief Description</td>
> </tr>
>
> <%
> 'Set the current record pointer to the first record of the recordset
> rs.MoveFirst
>
> 'Loop through all the records in the recordset
> while not rs.EOF
>
> 'Load recordset field values into local variables
> 'Note concatenating a zero-length string on the end of the field
> 'value automatically converts Null values into zero-length strings!!
> 'USE THIS APPROACH FROM NOW ON!
>
> ID = rs("productID") & ""
> name = rs("productName") & ""
> cDesc = rs("categoryDescription") & ""
> model = rs("modelName") & ""
> price = rs("price") & ""
> bDescription = rs("briefDescription") & ""
>
>
> 'Format the sales value, if there is a value for it
> 'Note: the FormatCurrency function REALLY doesn't like empty
>strings,
> ' so from now on be sure and check for them before using
>FormatCurrency.
> If price <> "" then
> price = FormatCurrency(price)
> End If
>%>
>
>
><tr>
> <td class="textMain"><%= ID %></td>
> <td class="textMain">
> <A HREF="DisplayIndividual.asp?qryProdID=<%= ID %>"><%
>name %></td>
> <td class="textMain"><%= cDesc %></td>
> <td class="textMain"><%= model %></td>
> <td class="textMain"><%= price %></td>
> <td class="textMain"><%= bDescription %></td>
> </tr>
>
></table>
>
></td>
> </tr>
>
> <tr>
> <td><!--#include file="../include/copyright.htm"--></td>
> </tr>
>
> </table>
>
> </td>
> </tr>
>
></table>
></BODY>
></HTML>
><%
>
>End Sub
>
>'------------------------------------------------
>' END OF PROCEDURES AND START OF MAIN CODE
>'------------------------------------------------
> dim rs
> dim sqlString
> dim ID, name, CCode, cDesc, model, price, bDescription
> dim connectionString, databaseName, path
> dim pageTitle
>
> 'Set connection details
> 'Note: this assumes that the database is in the same
>folder/directory
> 'as this asp file
> path = Server.MapPath(".")
> databaseName = "../data/store.mdb"
> 'connectionString = "DRIVER={Microsoft Access Driver (*.mdb)};" & _
> ' "DBQ=" & path & "\" & databaseName & ";"
> connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" _
> & path & "\" & databaseName
>
> 'Get video category code
> CCode = Request.Form("selProduct")
>
> 'Set sql string
> sqlString = "Select * from tblCategories, tblAmplifiers"
> sqlString = sqlString & " Where
>tblCategories.categoryCode=tblAmplifiers.categoryCode"
>
> If CCode <> "" Then
> sqlString = sqlString & " AND tblCategories.categoryCode='" &
>CCode & "'"
> End If
>
> 'Set page title variable
> if CCode = "" then
>
> pageTitle = "All Categories"
>
> else
>
> pageTitle = CCode
>
> end if
>
>
> sqlString = sqlString & " Order By ProductName"
>
> 'Debug printing (comment this out for your final version)
> 'response.write "sqlString = " & sqlString & "<p>"
>
> 'Create a recordset
> set rs = Server.CreateObject("ADODB.Recordset")
> rs.Open sqlString, connectionString
>
> Call DrawPage()
>
> 'Close the recordset
> rs.Close
> Set rs = Nothing
>
>%>
>
>
>Thanks ahead of time
>Lori
_________________________________________________________________
Protect your PC - get McAfee.com VirusScan Online
http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963
Message #4 by "Ken Schaefer" <ken@a...> on Mon, 18 Nov 2002 12:58:11 +1100
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: "Charles Mabbott" <aa8vs@m...>
Subject: [access_asp] Re: Expected statement - End Sub
: Rather than trying to generate the page as a subroutine there is no reason
: not to combine the html, asp code in the same page and put the proper HTML
: commands in there proper places. It will end up being a much cleaner and
: easier to follow page.
: Regards,
: Chuck
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
You are kidding right? :-)
Try to separate the HTML from the ASP as much as possible...
(...but that's not what the original poster was doing...)
Cheers
Ken
|
|
 |