ASP 101 - Active Server Pages 101 - Web06
The Place ASP Developers Go!

Please visit our partners

Windows Technology Windows Technology
15 Seconds
ASP 101
ASP Wire
VB Forums
VB Wire
internet.commerce internet.commerce
Partners & Affiliates

ASP 101 is an site
ASP 101 is an site
Internet News
Small Business
Personal Technology

Corporate Info
Tech Jobs
E-mail Offers

ASP 101 News Flash ASP 101 News Flash

ASP Source Code:
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=;" _
        & "Initial Catalog=samples;User Id=samples;Password=password;" _
        & "Connect Timeout=15;Network Library=dbmssocn;"
' Start the table
Response.Write "<table border=""1"">" & vbCrLf
' Write Titles
Response.Write vbTab & "<tr>" & vbCrLf
For Each objField in rstHighlight.Fields
    Response.Write vbTab & vbTab & "<td bgcolor=""#CCCCCC""><strong>"
    Response.Write objField.Name
    Response.Write "</strong></td>" & vbCrLf
Next 'objField
Response.Write vbTab & "</tr>" & vbCrLf
' Loop through records outputting data
Do While Not rstHighlight.EOF
    ' Alternate row color
    blnColor = Not blnColor
    If blnColor Then
        strColor = "#CCCCFF"  ' Light blueish
        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 & "<tr bgcolor=""" & strColor & """ " _
        & "onMouseOver=""this.bgColor='yellow'"" " _
        & "onMouseOut=""this.bgColor='" & strColor & "'"">" & vbCrLf
    ' Loop over the fields showing the current record's data.
    For Each objField in rstHighlight.Fields
        Response.Write vbTab & vbTab & "<td>" & objField.Value & "</td>" & vbCrLf
    Next 'objField
    Response.Write vbTab & "</tr>" & vbCrLf
' End the table
Response.Write "</table>" & vbCrLf
' Close and dispose of recordset object
Set rstHighlight = Nothing
To see the highlighting in action, try mousing over the rows of the table.

Back the the Sample Output

Back to the Sample Index

Home |  News |  Samples |  Articles |  Lessons |  Resources |  Forum |  Links |  Search |  Feedback
The Network for Technology Professionals



Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers