Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create Procedure not working?

Status
Not open for further replies.

timoteius

Technical User
Apr 7, 2006
9
0
0
GB
Hi everyone, Im pretty new to asp, so sorry if the solution is obvious. Ok so im trying to create a stored procedure to retrieve information regarding new releases from my database. However I keep getting this error

Code:
Microsoft VBScript compilation  error '800a0401'
Expected end of statement
/index.asp, line 5
CREATE PROCEDURE up_GetNewReleasesTop3

im grateful for any help, my code follows

Code:
'index page
<%
<!-- #include file="include\config.asp" -->

CREATE PROCEDURE up_GetNewReleasesTop3 
AS

  Select Distinct Top 3
    tblArtists.ArtistName,
    tblProducts.ProductTitle,
    tblProducts.releaseDate,
    tblProducts.price
  From
    tblProducts
  InnerJoin
    tblArtists
  ON 
    tblArtists.artistID = tblProduct.artistID
  WHERE
    tblProducts.releaseDate <= GetDate()

  Order by tblProducts.releaseDate DESC

  Go



Function GenerateNewReleases()
   Dim HTMLString 'as String
   Dim sqlQuery 'as String
   Dim rs 'as ADODB.RecordSet
   sqlQuery = "up_GetNewReleasesTop3"
   Set rs = Server.CreateObject("ADODB.RecordSet")
   Set rs = dbConn.Execute(sqlQuery)


  If rs.EOF and rs.BOF Then
    HTMLString="Sorry, there are no new Releases available for purchase at this time"
  Else
    Do Whole Not rs.Eof
	HTMLString = HTMLString & "<b>" & rs("ArtistName") & "</b> -- "
	HTMLString = HTMLString & "<i>" & rs("ProductTitle") & </i> -- "
	HTMLString = HTMLString & rs("releaseDate") & " "
	HTMLString = HTMLString & rs("price") & vbcrlf
        rs.MoveNext
    Loop
  End IF
  Set rs = Nothing
  GenerateNewRelease = HTMLString

 End Function

%>

<html>
 <head>
  <Title> Multimedia Warehouse </title>
 </head>
 
 <body>  

 <%
  'Declaring String Variables to be used to store output from procedures

  Dim newReleaseHTML 'as String
  Dim bestSellersHTML 'as String

  'procedure results are now stored in variables
  newReleaseHTML = GenerateNewReleases()
  bestSellersHTML = GeneratebestSellers()
 %>

'table is created to diasply the resutls onthe index page
<table width = "99%" cellspacing=5 cellpadding=5 border=0>
 <tr>
   <td valign="top">
     <h1> New Releases </h1>
        'displaying contents of variable in current place on page
 	<%=newReleasesHTML%>
   </td>
 </tr>

 <tr>
   <td valign="top">
     <h1> Current Best Sellers </h1> 
        'displaying contents of variable in current place on page
	<%=bestSellersHTML%>
   </td>
 </tr>
</table>
Cheers, Tim
 
you have to create the procedure at the database level and not at the asp page level...

-DNG
 
Many Thanks, I never knew you could do that.
 
... unless there is some strange reason that you want your ASP to create a stored procedure... and even then it would only work once because after the first execution you would need a ALTER PROCEDURE statement instead of CREATE .... I guess you could do a DROP PROCEDURE at the bottom ...

heheheh


Naw man, just paste your CREATE PROCEDURE statement into the Query Analyzer program and mash the little green arrow.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top