<%
Const adInteger = 3
Const adVarChar = 200
'Declare Variables
Dim myRecordset
Dim iLetter
Dim Field
Dim strAltColor
Dim bColor
BColor = False
'This example uses the recordset in memory. All you need to do is modify the display part of your data.
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 letter:" & Chr (iLetter )&"."
MyRecordset. Update
Next 'Letter
'Move to the start position of the header to start the following loop.
MyRecordset. MoveFirst
'Show data in the table
Response. Write "<table border =" "0" "cellspacing =" "0" "cellpadding =" 3 ">" & vbCrLf
'Header
Response. Write vbTab & "<tr>" & vbCrLf
For Each Field in myRecordset. Fields
Response. Write vbTab & "<td bgcolor =" "# CCCCCC" "> <strong>"
Response. Write Field. Name
Response. Write "</strong> </td>" & vbCrLf
Next 'field
Response. Write vbTab & "</tr>" & vbCrLf
Do While Not myRecordset. EOF
'Cycle to change the background color of the cell
BColor = Not bColor
If bColor Then
StrAltColor = "# FFFFFF"
Else
StrAltColor = "# FF8040"
End If
'Cycle to change the background color of the cell
Response. Write vbTab & "<tr>" & vbCrLf
For Each Field in myRecordset. Fields
Response. Write vbTab & "<td bgcolor = """
Response. Write strAltColor
Response. Write ""> "& Field. Value &" </td> "& vbCrLf
Next 'field
Response. Write vbTab & "</tr>" & vbCrLf
MyRecordset. MoveNext
Loop
'End the table
Response. Write "</table>" & vbCrLf
'Close objects and release resources
MyRecordset. Close
Set myRecordset = Nothing
%>