troubleshooting Question

SQL Query

Avatar of Stefan Motz
Stefan MotzFlag for United States of America asked on
ASPMicrosoft SQL Server 2008
4 Comments1 Solution305 ViewsLast Modified:
On my classic ASP page I provide users a search option with the instructions "Search by any of the below". When at lease the StartDate and EndDate are selected the query returns the correct values. But when users don't select the StartDate and EndDate, the query won't return the expected results. I would like all data returned when no date is selected. This is my query, I would appreciate your help:

SELECT * FROM myTable WHERE (Store LIKE '%" & Request.Form("Store") & "%' AND (RcvdDate between '" & Request.Form("StartDate") & "' AND '" & Request.Form("EndDate") & "') AND Product LIKE '%" & Request.Form("Product") & "%' AND Emp_Name LIKE '%" & replace(request.Form("Emp_Name"),"'","''") & "%'  AND Irreg LIKE '%" & Request.Form("Irreg") & "%' AND Emp_Id LIKE '%" & Request.Form("Emp_Id") & "%' AND Supervisor LIKE '%" & replace(request.Form("Supervisor"),"'","''") & "%' AND Authorized LIKE '%" & Request.Form("Authorized") & "%' AND Paid LIKE '%" & Request.Form("Paid") & "%') order by RcvdDate
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 4 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros