ClassData




Option Explicit
'**********************************************************

'In your ASP page

'Set obj = Server.CreateObject("ASP.clsASP")

'obj.Show_Record_Set("sp_myproc","Test Table",Response")

'**********************************************************

'You need a ref to ASP.dll and ADO

'Color Constants

Private Const PageBgColor As String = """#F5F5F5"""
Private Const TableBgColor As String = """#8F9FE9"""
Private Const ShadeBgColor As String = """#D7DEE8"""
'DSN

Private Const sConn As String = "Your DSN"
Function Show_Record_Set(ByVal sSQL As String, _
ByVal sHeading As String, _
ASP_Response As ASPTypeLibrary.Response)
On Error GoTo ASP_ERROR
Dim iDetailCount As Integer
Dim sRowBgColor As String
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
Dim fld As ADODB.Field
rs.Open sSQL, sConn
'Make a Table

With ASP_Response
.Write "<TABLE CELLPADDING=3 BORDER=""0"">"
.Write "<TR>"
.Write "<TD WIDTH=""100%"" HEIGHT =""18" & _
" COLSPAN =" & rs.Fields.Count & _
" BGCOLOR ="" #666699""><FONT SIZE = ""4" & _
" FACE = "" Tahoma"" COLOR = ""#FFFFFF"">" & _
sHeading & "</FONT></TD>"
.Write "</TR>"
'Create the column headings from the field name

.Write "<TR>"
For Each fld In rs.Fields
.Write " <TD bgcolor =" & TableBgColor _
& ">" & fld.Name & "</TD>"
Next
.Write "</TR>"
'Process each record building rows in table

iDetailCount = 1
Do While Not rs.EOF
.Write "<TR>"
'Shade each alternating row

If (iDetailCount Mod 2) = 0 Then
sRowBgColor = ShadeBgColor
Else
sRowBgColor = PageBgColor
End If
For Each fld In rs.Fields
.Write "<TD BGCOLOR= " & _
sRowBgColor & ">" & _
fld.Value & "" & "</TD>"
Next fld
.Write "</TR>"
rs.MoveNext
iDetailCount = iDetailCount + 1
Loop
'Close the table and object

.Write "</TABLE>"
End With
Set rs = Nothing
Exit Function
ASP_ERROR:
Err.Raise vbObjectError + 1, Err.Source, Err.Description
End Function

Option Explicit
'**********************************************************

'In your ASP page

'Set obj = Server.CreateObject("ASP.clsASP")

'obj.Show_Record_Set("sp_myproc","Test Table",Response")

'**********************************************************

'You need a ref to ASP.dll and ADO

'Color Constants

Private Const PageBgColor As String = """#F5F5F5"""
Private Const TableBgColor As String = """#8F9FE9"""
Private Const ShadeBgColor As String = """#D7DEE8"""
'DSN

Private Const sConn As String = "Your DSN"
Function Show_Record_Set(ByVal sSQL As String, _
ByVal sHeading As String, _
ASP_Response As ASPTypeLibrary.Response)
On Error GoTo ASP_ERROR
Dim iDetailCount As Integer
Dim sRowBgColor As String
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
Dim fld As ADODB.Field
rs.Open sSQL, sConn
'Make a Table

With ASP_Response
.Write "<TABLE CELLPADDING=3 BORDER=""0"">"
.Write "<TR>"
.Write "<TD WIDTH=""100%"" HEIGHT =""18" & _
" COLSPAN =" & rs.Fields.Count & _
" BGCOLOR ="" #666699""><FONT SIZE = ""4" & _
" FACE = "" Tahoma"" COLOR = ""#FFFFFF"">" & _
sHeading & "</FONT></TD>"
.Write "</TR>"
'Create the column headings from the field name

.Write "<TR>"
For Each fld In rs.Fields
.Write " <TD bgcolor =" & TableBgColor _
& ">" & fld.Name & "</TD>"
Next
.Write "</TR>"
'Process each record building rows in table

iDetailCount = 1
Do While Not rs.EOF
.Write "<TR>"
'Shade each alternating row

If (iDetailCount Mod 2) = 0 Then
sRowBgColor = ShadeBgColor
Else
sRowBgColor = PageBgColor
End If
For Each fld In rs.Fields
.Write "<TD BGCOLOR= " & _
sRowBgColor & ">" & _
fld.Value & "" & "</TD>"
Next fld
.Write "</TR>"
rs.MoveNext
iDetailCount = iDetailCount + 1
Loop
'Close the table and object

.Write "</TABLE>"
End With
Set rs = Nothing
Exit Function
ASP_ERROR:
Err.Raise vbObjectError + 1, Err.Source, Err.Description
End Function











( classdata.html )- by Paolo Puglisi - Modifica del 17/12/2023