Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
jamesnoony
Starting Member
2 Posts |
Posted - 2006-03-16 : 15:15:25
|
| HiI have a recordset the pulls the products from a stored procedure.I need a drop down list that will pull DISTINCT BrandName's from those results. I would then use that list to filter the results. How should I approach this? Do I need to create another recordset or can I use the rsProducts?Thanks, James<%Dim rsProducts__SubCatIDrsProducts__SubCatID = "1"If (Request("SubCatID") <> "") Then rsProducts__SubCatID = Request("SubCatID")End If%><%Dim rsProducts__BrandNamersProducts__BrandName = "%"If (Request("BrandName") <> "") Then rsProducts__BrandName = Request("BrandName")End If%><%Dim rsProductsDim rsProducts_numRowsSet rsProducts = Server.CreateObject("ADODB.Recordset")rsProducts.ActiveConnection = MM_connChameleon_STRINGrsProducts.Source = "{call spProducts(" + Replace(rsProducts__SubCatID, "'", "''") + ",'" + Replace(rsProducts__BrandName, "'", "''") + "')}"rsProducts.CursorType = 0rsProducts.CursorLocation = 3rsProducts.LockType = 1rsProducts.Open()rsProducts_numRows = 0%>CREATE PROCEDURE spProducts @SubCatID [int], @BrandName VARCHAR(255)=NULL ASSELECT dbo.tblProdCategories.ProductID, dbo.tblProdCategories.SubCatID, dbo.tblProducts.BrandName, dbo.tblProducts.ProdCode, dbo.tblProducts.ProdName, dbo.tblProducts.ProdDescription, dbo.tblProducts.UnitRRPrice, dbo.tblProducts.UnitPricegen, dbo.tblProducts.UnitPricemem, dbo.tblProducts.LineItemTax, dbo.tblProducts.DiscountedFlag, dbo.tblProducts.BestSellerFlag, dbo.tblProducts.PageFileName,dbo.tblProducts.Discontinued, dbo.tblProducts.DateAddedFROM dbo.tblProdCategories INNER JOINdbo.tblProducts ON dbo.tblProdCategories.ProductID = dbo.tblProducts.ProductIDWHERE dbo.tblProdCategories.SubCatID=@SubCatID AND dbo.tblProducts.Discontinued = 0 AND dbo.tblProducts.BrandName LIKE COALESCE(@BrandName, BrandName)GO |
|
|
jhermiz
3564 Posts |
Posted - 2006-03-16 : 18:29:55
|
The spProducts takes a parameter of @BrandName, do you need that? You are asking us a question that you should be able to tell us whether or not you need that. What is it exactly (show us your data, sample data, any code, etc) that you want to do?If it is just filling up the products combo box or grid or list then yes create another sproc that does not take the @BrandName parameter.SELECT ProductID, Product FROM Product ORDER BY ProductThen fill your product combo box. Then to load the Brands of the product you write a sproc that goes into your other table and selects data based on the productidSELECT BrandID, Brand FROM Brand WHERE ProductID = @ProductIDThis will then filter the brands based on the Product.Jon Keeping the web experience alive -- [url]http://www.web-impulse.com[/url]RS Blog -- [url]http://weblogs.sqlteam.com/jhermiz[/url] |
 |
|
|
jamesnoony
Starting Member
2 Posts |
Posted - 2006-03-17 : 06:49:17
|
| Ok...The SP for products all works fine and I do need the @BrandNameIt would by default have a query string into the page such as/products.asp?SubCatID=3(At that point it is NOT using the @BrandName) and would pull a set of results such asSony ABC 123Sony DSC 345Sony BGT 123Phillips 567Phillips 789Aiwa 678Aiwa 836But the idea is I would then have a drop down list that would have a list of distinct BrandNames (filtered from the SubCatID), ie the list would look likeShow All BrandsSonyPhillipsAiwaThe list would then post to the page with the querystring/products.asp?SubCatID=3&BrandName=SonyThe results would then be justSony ABC 123Sony DSC 345Sony BGT 123ie the @BrandName is an optional parameter in the SPHope that makes it a little clearer. Thanks, James |
 |
|
|
|
|
|
|
|