Search string
First thing I see (which won't net you much) is the loop to build the search string:
Code:
DO WHILE i <= UBound(arrFinalSearch)
IF i = 0 THEN
strUserSearchedFor = "%" & arrFinalSearch(i) & "%"
ELSE
strUserSearchedFor = strUserSearchedFor & " %" & arrFinalSearch(i) & "%"
END IF
i = i + 1
LOOP
can be replaced with:
strUserSearchedFor = "%" & Join(arrFinalSearch,"%") & "%"
Recordset
The biggest gain you will get will be not using Recordset.Open and instead using the connection object to get the recordset, then recordset.GetRows to push the data into an array. More info on GetRows() here:
Code:
[b]original[/b]
SET oRS = Server.CreateObject("ADODB.Recordset")
oRS.Open strSQL, oConn, 0, 1
[b]Replaced with[/b]
'I am assuming that oConn is an ADODB.Connection object
' execute query to recordset object
Set oRS = oConn.Execute strSQL
' declare and build array
Dim arrData
arrData = oRS.GetRows()
'clean up recordset
Set oRS = Nothing
Once you have the data in an array then you will loop through the array based on the second index (rows are second index, fields are first index):
Code:
[b]Original:[/b]
DO WHILE NOT oRS.EOF
'...
oRS.MoveNext
LOOP
[b]Replacement:[/b]
Dim rowCtr
For rowCtr = 0 to UBound(arrData,2)
'...
Next
And then the last step would be to replace references to oRS with calls to the array. As I mentioned before, the two-dimensional array that GetRows() creates has the row number as it's second dimension and the field number as it's first dimension. The field name order is based on the order used in your select statement. Here are some examples:
Code:
[b]Before:[/b] ArtistTitle = ConvertName(oRS.Fields("Artist_Title"))
[b]After:[/b] ArtistTitle = ConvertName(arrData(0,rowCtr))
[b]Before:[/b] strResults = strResults & oRS.Fields("Price") & "0</td>"
[b]After:[/b] strResults = strResults & arrData(1,rowCtr) & "0</td>"
String Concatenation
VBScript is notoriously bad about string concatenation performance. One solution to this is to build your own buffer (basically an array) and instead of concatenating the strings, simply assign each on to the array in order, then perform a Join(yourArray,"") when you want to output it. This has been shown to be a great deal more efficient. If your interested you can find more info in mwolf's posts in this thread: thread333-610504
CSS
I would actually suggest redesigning some of your code in the loop as well. If you can trim down the code by 30 or 40 characters and you generally have 25 records to display, then you have effectively cut out 750 characters. Plus the simpler you make that table the faster the end browser will be able to render it. I would have to see your page to make more recomendations, but for starters you could easily get rid of all of those spacer gifs and use CSS padding for the majority of it.
Here is a sample of a row that could come out of your loop (spaced out for easier reading):
Code:
<tr>
<td width="50%" class="MainTxt">Some Artist</td>
<td width="1" bgcolor="#990000"><img src="images/spacer.gif" alt="*" height="1" width="1" /></td>
<td width="10%" class="MainTxt">
<table width="95%" border="0" cellpadding="1" cellspacing="0" align="center">
<tr>
<td>Some Category</td>
</tr>
</table>
</td>
<td width="1" bgcolor="#990000"><img src="images/spacer.gif" alt="*" height="1" width="1" /></td>
<td width="15%" class="MainTxt">
<table width="95%" cellpadding="1" cellspacing="0" border="0" align="center">
<tr><td>Some Retailer</td></tr>
</table>
</td>
<td width="1" bgcolor="#990000"><img src="images/spacer.gif" alt="*" height="1" width="1" /></td>
<td width="10%" class="MainTxt">
<div align="center">£30
</td>
<td width="1" bgcolor="#990000"><img src="images/spacer.gif" alt="*" height="1" width="1" /></td>
<td width="5%">
<table width="95%" cellpadding="1" cellspacing="0" border="0" align="center">
<tr><td><img src="someImage.jpg" alt="Art Work" width="60" height="60" /></td></tr>
</table>
</td>
<td width="1" bgcolor="#990000"><img src="images/spacer.gif" alt="*" height="1" width="1" /></td>
<td width="10%">
<div align="center">
<a href="DoLink.asp?URL=someProduct.html&Art=SomeArtist" class="Purchase" target="_blank">Buy</a>
</div>
</td>
<td width="1" bgcolor="#990000"><img src="images/spacer.gif" width="1" height="1" alt="*" />
</tr>
<tr>
<td bgcolor="#FFFFFF"><img src="images/spacer.gif" alt="*" height="2" width="1" /></td>
<td bgcolor="#990000"><img src="images/spacer.gif" alt="*" height="1" width="1" /></td>
<td bgcolor="#FFFFFF"><img src="images/spacer.gif" alt="*" height="2" width="1" /></td>
<td bgcolor="#990000"><img src="images/spacer.gif" alt="*" height="1" width="1" /></td>
<td bgcolor="#FFFFFF"><img src="images/spacer.gif" alt="*" height="2" width="1" /></td>
<td bgcolor="#990000"><img src="images/spacer.gif" alt="*" height="1" width="1" /></td>
<td bgcolor="#FFFFFF"><img src="images/spacer.gif" alt="*" height="2" width="1" /></td>
<td bgcolor="#990000"><img src="images/spacer.gif" alt="*" height="1" width="1" /></td>
<td bgcolor="#FFFFFF"><img src="images/spacer.gif" alt="*" height="2" width="1" /></td>
<td bgcolor="#990000"><img src="images/spacer.gif" alt="*" height="1" width="1" /></td>
<td bgcolor="#FFFFFF"><img src="images/spacer.gif" alt="*" height="2" width="1" /></td>
<td width="1" bgcolor="#990000"><img src="images/spacer.gif" width="1" height="1" alt="*" />
</tr>
There is a lot of repetitive HTML in there that we could replace for smaller output and greater ease of modification. In fact you could replace the spacer images in that loop and the extra padding cells in the second row with something like the following CSS:
Code:
border-right: 3px solid #990000;
padding-bottom: 2px;
Obviously I don't have your CSS, so I can't see exactly how this would be layed out, but adding that to the MainTxt class (or making a specialized class for the table cells) would allow you to trim the HTML in the loop down to something like:
Code:
<tr>
<td width="50%" class="MainTxt">Some Artist</td>
<td width="10%" class="MainTxt">Some Category</td>
<td width="15%" class="MainTxt">Some Retailer</td>
<td width="10%" class="MainTxt">£30</td>
<td width="5%" class="MainTxt"><img src="someImage.jpg" alt="Art Work" width="60" height="60" /></td></td>
<td width="10%" class="MainTxt"><a href="DoLink.asp?URL=someProduct.html&Art=SomeArtist" class="Purchase" target="_blank">Buy</a></td>
</tr>
You may need to also specify the background-color: #ffffff in your CSS or make other minor alterations, but moving all of your presentation stuff to the CSS means you have finer control over it and saved yourself something like 2KB per loop. That is that much less an end user has to download, that much less the server has to buffer/concatenate/etc, and that much less complexity that the browser has to render.
In any case, I hope these help you. I would highly recommend trying to reduce the amount of HTML your outputting for presentation and move as much of it as possible to CSS. The advantages far out-weigh the time taken to design and make the modifications.
-T