troubleshooting Question

SQL query return a result when it should not

Avatar of djpazza
djpazza asked on
Microsoft AccessASP
3 Comments1 Solution323 ViewsLast Modified:
I have a products table in access which I'm querying using asp vb script.  For each product you can assign a categoryid and the categories are storde in a separate table.

An administrator has requested the ability to list the product in more than one category so I have added another column in the product table called 'additionalcat1'.

I have then updated my sql query to include the new column.  I have also got in my query only to display active products.

When the product is not active the attached query shows the product listed using the querystring additionalcat1.  It does not list it using the querystring categoryid which is correct but i can not figure out why it displays at all if I'm only displaying active products.
<%
Dim rsbrowcat__MMColParam2
rsbrowcat__MMColParam2 = "0"
If (request.QueryString("CategoryID")  <> "") Then 
  rsbrowcat__MMColParam2 = request.QueryString("CategoryID") 
End If
%>
<%
Dim rsbrowcat__MMColParam
rsbrowcat__MMColParam = "0"
If (Request.QueryString("CategoryID")  <> "") Then 
  rsbrowcat__MMColParam = Request.QueryString("CategoryID") 
End If
%>
<%
Dim rsbrowcat
Dim rsbrowcat_cmd
Dim rsbrowcat_numRows

Set rsbrowcat_cmd = Server.CreateObject ("ADODB.Command")
rsbrowcat_cmd.ActiveConnection = MM_bimishop_STRING
rsbrowcat_cmd.CommandText = "SELECT * FROM Products p WHERE p.active = True AND p.CategoryID = ? OR p.additionalcat1 = ?  " 
rsbrowcat_cmd.Prepared = true
rsbrowcat_cmd.Parameters.Append rsbrowcat_cmd.CreateParameter("param1", 5, 1, -1, rsbrowcat__MMColParam2) ' adDouble
rsbrowcat_cmd.Parameters.Append rsbrowcat_cmd.CreateParameter("param2", 5, 1, -1, rsbrowcat__MMColParam) ' adDouble

Set rsbrowcat = rsbrowcat_cmd.Execute
rsbrowcat_numRows = 0
%>
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
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 3 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