Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can this code be better

Status
Not open for further replies.

gsc123

Programmer
Jan 24, 2008
197
Could this code be better as a query rather than wrapping a execute in this loop?

first query is

SELECT products.Description, products.Price, products.ImageUrl, products.idproduct, products.endDate, suppliers.idsupplier, suppliers.supplierName FROM suppliers INNER JOIN products ON suppliers.idsupplier = products.idsupplier WHERE idcategory=21 and ListHidden = false




do while not rsTempProducts.eof and count < rsTempProducts.pageSize

pidProduct = rsTempProducts("idproduct")
pDescription = rsTempProducts("description")
'pPrice = rsTempProducts("price")
sql = "SELECT Min(bidAmount) AS price FROM BidHistory WHERE (((BidHistory.bidAmount) In (SELECT Min(BidAmount) FROM BidHistory WHERE BidAmount<10009999 and idproduct = "&pidProduct&")))"
set rsMin = conntemp.execute(sql)
pPrice = rsMin("price")
pImageURL = rsTempProducts("imageURL")
pEndDate = rsTempProducts("endDate")
pSupplierName = rsTempProducts("supplierName")
pIdSupplier = rsTempProducts("idsupplier")
%><!--#include file="itemdetailsm.asp"--><%
count = count + 1
rsTempProducts.MoveNext
loop
 
Code can always be better...

Is there something wrong with the way it currently reads or are you just looking to condense it?

What kind of db are you using, and what exactly are you doing with the code?

you could consolidate everything into one massve query, return a big recordset and parse through it...

Your do while loop should be an OR, as if you reach the end of the RS before the count is less than the page size, it will continue to execute.


--------
GOOGLE is a great resource to find answers to questions like "how do i..."

If you don't know exaclty what you want to do or what to search on, try Google Suggest: --------
I have recently been semi-converted to ensuring all my code (well most of it) works in both javascript and non-javasc
 
Its just the running sql statement for each product, if there's 500 products, imagine that times 2000 users, its a lot of connections, could sql server cope this that>? dont think access would
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top