Hello,
Hope someone can help ... I'm adapting the Classified application in BEGINNING ASP 3.0 to a comic-book collection tracker. Consequently, I'm making some changes to the way the application works. I've run into a couple of problems, that ought to be easy, but are giving me sleepless nights. Here's the first problem.
When selecting an item in the database to edit the details for the use clicks a linked ID number on a table and this brings up a details form with fields filled in from corresponding fields in the database. Pretty, standard, right? Except that it's not working for me and I can't see why.
Here's the relevant code from the ViewMyComics.asp page ...
Code:
<%
Dim rsItems
Set rsItems = Server.CreateObject("ADODB.Recordset")
rsItems.Open "Item", objConn, adOpenForwardOnly, adLockOptimistic, adCmdTable
If Not rsItems.EOF Then ' current user has items for sale
Response.Write _
"<table border=""1"" cellspacing=""2"" cellpadding=""2"">" & _
"<tr>" & _
" <th>ID</th>" & _
" <th>Issue</th>" & _
" <th>Condition</th>" & _
" <th>Month</th>" & _
" <th>Year</th>" & _
"</tr>"
Do While Not rsItems.EOF
Response.Write _
"<tr align=center>" & _
" <td><a href=""item.asp?Action=Edit&Item=" & rsItems("idItem") & """>" & _
rsItems("idItem") & "</a></td>" & _
" <td>" & rsItems("issue") & "</td>" & _
" <td>" & rsItems("cond") & "</td>" & _
" <td>" & rsItems("month") & "</td>" & _
" <td>19" & rsItems("year") & "</td>" & _
"</tr>"
rsItems.MoveNext
Loop
Response.Write "</table>"
Else ' user has no items in the database
Response.Write "<center><h2>No comics saved in database</h2></center>"
End If
rsItems.close
%>
My DB field changes the fieldname from "ItemID" to "idItem" but that shouldn't affect the function ..
The code on the Item.asp page should receive the idItem value and display the relevant data in the form fields. But it doesn't. It just displays the data from the first row of the DB table "Item" ... Here's the Item.asp code:
Code:
<%
If blnNew Then %>
<input type="Hidden" name="idItem" value=""> <%
Else %>
<input type="Hidden" name="idItem" value="<%= Request("Item") %>"> <%
End If
%>
Subsequent to this problem, I have the names of the comic titles ("Amazing Spider-Man", "Journey into Mystery") stored in a separate table, "Title". This is good DB practice, right? But when I try to substitute the Table name "Item" in the ViewMyComics.asp page, I get a SQL error message complaining about the syntax. This is a SQL statement that works just fine on the page that displays the actual table of comics, which can be seen here:
http://www.thestoryworks.com/publish...ng/default.asp
The SQL statement that I know works elsewhere is:
Code:
Dim rsItem
Set rsItem = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT Title.titleName, Item.idItem, Item.issue, Item.[month], Item.[year], " & _
" Item.cond, Item.gcdb, Item.image, Item.cents, Item.have, Item.want, Item.note " & _
" FROM Title INNER JOIN Item ON Title.idTitle = Item.idTitle " & _
" ORDER BY titleName,month;"
rsItem.Open strSQL, objConn, adOpenForwardOnly, adLockOptimistic, adCmdText
So how do I retrieve the comic book title to include in the ViewMyComics.asp page, and how do I pass the correct ID to the Item.asp page?
Any help would be hugely appreciated ...
Best,
Alan M, London