SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Member
    Join Date
    Jan 2011
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Mismatch Criteria Problem - Appending URL

    Hey guys,

    I generally don't post on these forums (I have just been reading the forums for a good few months) - But I have an issue that I cannot solve at the moment.

    I have one page appending an OrderID via details, so that when it calls orders.asp it displays the url orders.asp?OrderID=10643

    This should then display on orders.asp the order history but it does not work;
    Its a basic HTML page and then;

    HTML Code:
    <%
    Set DBConnection = Server.CreateObject("ADODB.Connection")
    DBConnection.Open "solutions"
    
    DETAIL_ID = Request.QueryString("OrderID")
    SQLQuery = "SELECT * FROM [Order Details] WHERE "
    SQLQuery = SQLQuery & "OrderID ='"& DETAIL_ID &"'"
    
    Set DBOutput = DBConnection.Execute(SQLQuery)
    %>
    And the table displaying;

    HTML Code:
    <table>
    <tr>
    <th>OrderID</th>>
    </tr>
    <% Do While Not DBOutput.Eof %>
    <tr>
    <td><%=DBOutput("OrderID")%>"></td>
    
    
    </tr>
    
    <%
    DBOutput.Movenext
    Loop
    Set DBOutput = Nothing
    DBConnection.Close
    Set DBConnection = Nothing
    
    %>
    </table>
    Table is setup just to see if it displays orderid

    Thanks for reading guys,

    Dan

  2. #2
    SitePoint Addict
    Join Date
    Apr 2009
    Posts
    357
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    What do you mean by 'does not work'? If you get error messages post the error and the asp code surrounding the line that causes the error
    Doug G
    =====
    "If you ain't the lead dog, the view is always the same - Anon

  3. #3
    SitePoint Guru
    Join Date
    Jun 2007
    Posts
    686
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OrderID looks to be a number but in your SQLQuery you're treating it like a string by wrapping it in single quotes.

    SQLQuery = SQLQuery & "OrderID ='"& DETAIL_ID &"'"

    if it is a number, you don't need the single quotes

    SQLQuery = SQLQuery & "OrderID = " & DETAIL_ID

  4. #4
    SitePoint Member
    Join Date
    Jan 2011
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    webber123456,

    Thank you - Your solution worked. Sadly, I now have a new error.

    The page displays the first value (OrderID) then it should display the Product, but it returns with the error;

    HTML Code:
    ADODB.Recordset error '800a0cc1'
    
    Item cannot be found in the collection corresponding to the requested name or ordinal.
    
    /orders.asp, line 46
    Which relates to;

    HTML Code:
    <table>
    <caption id="captions">Order Results</caption>
    
    <tr>
    <th>OrderID</th><th>Product</th><th>Unit Price</th><th>Quantity</th><th>Discount</th>
    </tr>
    <% Do While Not DBOutput.Eof %>
    <tr>
    <td><%=DBOutput("OrderID")%></td>
    <td><%=DBOutput("Product")%></td>
    <td><%=DBOutput("Unit Price")%></td>
    <td><%=DBOutput("Quantity")%></td>
    <td><%=DBOutput("Discount")%></td>
    
    </tr>
    
    <%
    DBOutput.Movenext
    Loop
    Set DBOutput = Nothing
    DBConnection.Close
    Set DBConnection = Nothing
    
    %>
    </table>
    The Product part of the code above - If I remove Product and Unit Price it will display just numerical data.

    I've checked the spelling and that it does exist in the database.

    Thanks,

    Dan

  5. #5
    SitePoint Guru
    Join Date
    Jun 2007
    Posts
    686
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    it's probably the field for "unit price" since it is two words.

    verify that the field name is in fact 2 words and that "unit price" is not a descriptive label.

    if the field name is 2 words then in your query you may need to put multi-word field names inside square brackets.

  6. #6
    SitePoint Member
    Join Date
    Jan 2011
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Problem solved.

    Thank you very much for your help! Greatly appreciated!

    Dan


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •