<% '******************************************************* '* ASP 101 Sample Code - http://www.asp101.com/ * '* * '* This code is made available as a service to our * '* visitors and is provided strictly for the * '* purpose of illustration. * '* * '* http://www.asp101.com/samples/license.asp * '* * '* Please direct all inquiries to webmaster@asp101.com * '******************************************************* %> <% Dim rstHighlight ' The recordset object Dim objField ' Field looper for display Dim blnColor ' Use for showing alternating colors Dim strColor ' Temp string to hold current bgcolor blnColor = True ' Create an instance of an ADO Recordset Set rstHighlight = Server.CreateObject("ADODB.Recordset") ' Open our recordset. Since I don't need a connection object for ' anything else, I'm not creating one. I simply use the connection ' string that I would have used to open the connection to open the ' recordset instead. rstHighlight.Open "SELECT * FROM scratch;", _ "Provider=SQLOLEDB;Data Source=10.2.2.133;" _ & "Initial Catalog=samples;User Id=samples;Password=password;" _ & "Connect Timeout=15;Network Library=dbmssocn;" ' Start the table Response.Write "" & vbCrLf ' Write Titles Response.Write vbTab & "" & vbCrLf For Each objField in rstHighlight.Fields Response.Write vbTab & vbTab & "" & vbCrLf Next 'objField Response.Write vbTab & "" & vbCrLf ' Loop through records outputting data Do While Not rstHighlight.EOF ' Alternate row color blnColor = Not blnColor If blnColor Then strColor = "#CCCCFF" ' Light blueish Else strColor = "#FFFFFF" ' White End If ' This is the line that enables the highlighting when you mouse ' over a table row. We use some simple client-side JavaScript ' to change the background color when we mouse over and change ' it back when the mouse moves back out. Response.Write vbTab & "" & vbCrLf ' Loop over the fields showing the current record's data. For Each objField in rstHighlight.Fields Response.Write vbTab & vbTab & "" & vbCrLf Next 'objField Response.Write vbTab & "" & vbCrLf rstHighlight.MoveNext Loop ' End the table Response.Write "
" Response.Write objField.Name Response.Write "
" & objField.Value & "
" & vbCrLf ' Close and dispose of recordset object rstHighlight.Close Set rstHighlight = Nothing %>

To see the highlighting in action, try mousing over the rows of the table.