I was browsing through the questions and noticed this:
SELECT prodid, issue FROM Sales WHERE custid = @custid AND datesold = SELECT MAX(datesold)
Its a parameter the you need to define. to prevent SQL Injection you should pass all your variables in as parameters.