<%@LANGUAGE="VBSCRIPT"%> <% Dim rsAdvertising Dim rsAdvertising_cmd Dim rsAdvertising_numRows Set rsAdvertising_cmd = Server.CreateObject ("ADODB.Command") rsAdvertising_cmd.ActiveConnection = MM_connIsleofWhithorn_STRING rsAdvertising_cmd.CommandText = "SELECT * From advertising WHERE adExpiry >= DATE_SUB(curdate(), INTERVAL 0 DAY) AND adShow = '1'" 'rsAdvertising_cmd.Prepared = true Set rsAdvertising = rsAdvertising_cmd.Execute rsAdvertising_numRows = 0 %> <% ' Moving to random record - Steven Jones' Extension If Not(rsAdvertising.bof and rsAdvertising.eof) Then ' reset the cursor to the beginning If (rsAdvertising.CursorType > 0) Then rsAdvertising.MoveFirst Else rsAdvertising.Requery End If rsAdvertising_totalrn = -1 rsAdvertising_totalrn = rsAdvertising.RecordCount ' ony works on some recordsets, but much faster If (rsAdvertising_totalrn = -1) Then ' and if it didn't work, we still have to count the records. ' count the total records by iterating through the recordset rsAdvertising_totalrn=0 While (Not rsAdvertising.EOF) rsAdvertising_totalrn = rsAdvertising_totalrn + 1 rsAdvertising.MoveNext Wend ' reset the cursor to the beginning If (rsAdvertising.CursorType > 0) Then rsAdvertising.MoveFirst Else rsAdvertising.Requery End If End If ' now do final adjustments, and move to the random record rsAdvertising_totalrn = rsAdvertising_totalrn - 1 If rsAdvertising_totalrn > 0 Then Randomize rsAdvertising.Move Int((rsAdvertising_totalrn + 1) * Rnd) End If End If ' all done; you should always check for an empty recordset before displaying data %> <% Function parseInput(strInput) strInput = Replace(strInput,"&", "&") strInput = Replace(strInput,"@", "@") strInput = Replace(strInput,"-", "-") strInput = Replace(strInput,"'", "'") parseInput = strInput End Function %> Map showing the location of the Isle of Whithorn

Map showing the location of the Isle of Whithorn

Home PageNewsEventsShop
The Isle of Whithorn

The Isle of Whithorn

Send us your comments...

The content of this website is maintained by members of the Isle of Whithorn Village community. If you have a comment or would like more information page please contact us.

<% rsAdvertising.Close() Set rsAdvertising = Nothing %>