The following is my MS sql-server statement, which is used in my C# Windows application. As the title suggests, it selects all product numbers that are between the Textbox dates. I’m fairly inexperienced with SQL, so my attempt may be an atrocity. SQL seems to think so.
string strSQL = "SELECT * FROM HISTORY ORDER BY productNumber WHERE (@strt_date >= '" + Convert.ToDateTime(KHDate1Box.Text) + "' and @end_date <= '" + Convert.ToDateTime(KHDate2Box.Text) + "')";
SQL error message: “Incorrect syntax near the keyword ‘WHERE’.”
That’s because the WHERE clause should come before
ORDER BY