Hi all,
First time posting here. Been using ASP for about a year but never really got to far into coding. I only learnt enough to get my site up and running as i was on a tight deadline. Im now upgrading the site and need a little help with the "Filte" properties of a RecordSet.
Im trying to group together similar records. Its basically a discography of albums that a band has released. I have been reading the code on chapter 13 page 549 which i could adapt to do what i want it to do but im getting stuck.
Here is the code i have.
Code:
<%@LANGUAGE="VBSCRIPT"%>
<% OPTION EXPLICIT %>
<link rel="stylesheet" href="includes/style.css" type="text/css">
<body bgcolor="#333333">
<%
Dim strSQL, ID
' strSQL = "SELECT Albums.AlbumsID, Albums.Album, Lyrics.LyricsID, Lyrics.Title, Lyrics.AlbumsID FROM Albums LEFT JOIN Lyrics ON Albums.AlbumsID=Lyrics.AlbumsID WHERE Lyrics.Active=1;"
strSQL = "SELECT Albums.AlbumsID AS Albums_AlbumsID, Albums.Name AS Albums_Name, Tracks.TracksID, Tracks.AlbumsID AS Tracks_AlbumsID, Tracks.LyricsID, Tracks.TabID, Tracks.Name AS Tracks_Name, Tracks.TrackNumber FROM Albums INNER JOIN Tracks ON Albums.AlbumsID = Tracks.AlbumsID;"
'Debug lines
response.write strSQL
response.flush
'Open DB connection
'objRS.CursorType = 3
objRS.Open strSQL, objConn, adOpenStatic, AdLockReadOnly, adCmdTable
objRS.Filter = objRS("Albums_Name")
Dim Count 'We'll use this to limit the number of records displayed on a page
Count = 1
Response.Write "<table border=1 cellpadding=0>"
Do While Not objRS.EOF
With Response
.Write "<tr class=""body"">"
.Write "<td>"
'.Write (objRS.Fields.Item("tblLyrics.fldTitle").Value)
'.Write (objRS.Fields.Item("tblLyrics.fldAlbum").Value)
.Write objRS("Albums_Name")
.Write "</td><td>"
.Write objRS("Tracks_Name")
.Write "</td><td>"
'.Write "<a href=""LyricsDetailPage.asp?ID=" & objRS("Lyrics.LyricsID") & """> Lyrics</a> "
.Write "</td></tr>"
End With
count = count + 1
'objRS.Filter = nothing
objRS.MoveNext
Loop
Response.Write "<tr><td align=center>"
Response.Write "</td></tr></table>"
Response.Write "<center>"
'Call BuildNav2 (intPrev,IntNext,TotalPages)
Response.Write "</center>"
objRS.close
Set objRS = Nothing
%>
</body>
</html>
When i run the page a i get the following error message.
Code:
SELECT Albums.AlbumsID AS Albums_AlbumsID, Albums.Name AS Albums_Name, Tracks.TracksID, Tracks.AlbumsID AS Tracks_AlbumsID, Tracks.LyricsID, Tracks.TabID, Tracks.Name AS Tracks_Name, Tracks.TrackNumber FROM Albums INNER JOIN Tracks ON Albums.AlbumsID = Tracks.AlbumsID;
Microsoft JET Database Engine error '80040e14'
Syntax error in FROM clause.
/beta/lyrics_iframe.asp, line 22
But if i take out the lines "adOpenStatic, AdLockReadOnly, adCmdTable" propertie i get the results printed on the page as expected.
Can someone explain where im going wrong? i've been at this for a few hours and i think i need a fresh pair of eyes.
Many thanks
Mike