Color.asp
Author: Amoy Net
Source: Amoy Net
NOTE: Reprint please indicate the source
<%
Const Adinteger = 3
Const adVarChar = 200
' Declare variables
Dim Myrecordset
Dim Iletter
Dim Field
Dim Straltcolor
Dim Bcolor
Bcolor = False
' This example takes advantage of an in-memory recordset and all you have to do is modify the portion of your data display.
Set myrecordset = Server.CreateObject ("ADODB. Recordset ")
MyRecordset.Fields.Append "ID", adinteger
MyRecordset.Fields.Append "Title", adVarChar, 25
MyRecordset.Fields.Append "Description", adVarChar, 255
Myrecordset.open
' Fill RS with sample data:
For iletter = ASC ("A") to ASC ("M")
Myrecordset.addnew
Myrecordset.fields ("ID"). Value = iLetter-64
Myrecordset.fields ("Title"). Value = "Letter:" & Chr (Iletter)
Myrecordset.fields ("Description"). Value = "Test the letters here:" & Chr (Iletter) & "."
Myrecordset.update
Next ' Iletter
' Move to the beginning of the head so that the following loop starts.
Myrecordset.movefirst
' Display data in a table
Response.Write "<table border=" "0" "cellspacing=" "0" "cellpadding=" "3" ">" & vbCrLf
' Table header
Response.Write VbTab & "<tr>" & VbCrLf
For each Field in Myrecordset.fields
Response.Write VbTab & VbTab & "<td bgcolor=" "#CCCCCC" "><strong>"
Response.Write Field.name
Response.Write "</strong></td>" & VbCrLf
Next ' Field
Response.Write VbTab & "</tr>" & VbCrLf
Do as not myrecordset.eof
' Loop changes the background color of a cell
Bcolor = Not Bcolor
If Bcolor Then
Straltcolor = "#FFFFFF"
Else
Straltcolor = "#FF8040"
End If
' Loop changes the background color of a cell
Response.Write VbTab & "<tr>" & VbCrLf
For each Field in Myrecordset.fields
Response.Write VbTab & VbTab & "<td bgcolor=" ""
Response.Write Straltcolor
Response.Write "" ">" & Field.value & "</td>" & VbCrLf
Next ' Field
Response.Write VbTab & "</tr>" & VbCrLf
Myrecordset.movenext
Loop
' End ' table
Response.Write "</table>" & VbCrLf
' Close objects, release resources
Myrecordset.close
Set myrecordset = Nothing
%>