Locate that
hard to find 80s song/Artist

|
 |
|
This is the ultimate top 10 chart of your individual
top 10s
This is instantly updated, so whoever submits a top
10 will be having a direct influence on this chart.
<%
' *************************************************************************
' GLOBAL CONSTANTS
' *************************************************************************
Const adUseClient = 3
' indicates that client cursor engine should be used
Const adStateOpen = 1
' used to determine wheter a data connection is open
Const adInteger = 3
' ADO value for an Integer data type
Const adSmallInt = 2
' ADO value for a small Integer data type
Const adLongVarWChar = 203
' ADO value for a Memo data type
Const adBoolean = 11
' ADO value for a Boolean data type
Const adVarWChar = 202
' ADO value for Variant character data type
Const adDate = 7
' ADO value for a Date data type
Const adCmdText = 1
' specifies that query is defined by .CommandText property
' *************************************************************************
' GLOBAL VARIABLES
' *************************************************************************
Dim gobjDataConn
' connection with database
' *************************************************************************
' MAIN CODE
' *************************************************************************
On Error Resume Next
If GetDatabaseConnection Then
ShowTopSongs
Else
Response.Write " "
DisplayMessage "It was not possible to display the Top 10 list. " _
& "If this problem can not be resolved by refreshing the page " _
& "please try again later.", "80%"
Response.End
End If
' *************************************************************************
' SERVER PROCEDURES
' *************************************************************************
FUNCTION GetDatabaseConnection
' ---------------------------------------------------------------------
' DESCRIPTION OF ROUTINE
' ---------------------------------------------------------------------
' Purpose: To establish a connection with the data source
' Assumptions: None
' Effects: None
' Inputs: None
' Returns: True/False value identifying whether connection was
' successfully established.
' ---------------------------------------------------------------------
On Error Resume Next
' ---------------------------------------------------------------------
' Attempt to open connection with data source
' ---------------------------------------------------------------------
Set gobjDataConn = Server.CreateObject("ADODB.Connection")
gobjDataConn.Open "File name=" & server.MapPath("Pure80sPop.udl")
' ---------------------------------------------------------------------
' Check for database connection error
' ---------------------------------------------------------------------
If gobjDataConn.State = adStateOpen Then
GetDatabaseConnection = TRUE
Else
GetDataBaseConnection = FALSE
End If
END FUNCTION
SUB ShowTopSongs()
' ---------------------------------------------------------------------
' DESCRIPTION OF ROUTINE
' ---------------------------------------------------------------------
' Purpose: To display a list of top songs.
' Assumptions: None
' Effects: None
' Inputs: None
' Returns: None
' ---------------------------------------------------------------------
On Error Resume Next
' ---------------------------------------------------------------------
' Declare variables
' ---------------------------------------------------------------------
Dim rstTopSongs
' recordset containing the top songs.
Dim rstData
' generic recordset
Dim strSQL
' query definition
Dim strCellValue
' cell value
Dim objField
' reference to ADO Field object
Dim intCol
' used to iterate fields in recordset
Dim intLineNo
' line number.
Dim lngRecordCnt
' number of Top 10 Item records
' ---------------------------------------------------------------------
' Get count of records to provide a percentage of vote
' ---------------------------------------------------------------------
strSQL = "SELECT Count(*) AS EXPR_RECORD_CNT FROM tblTop10Hdr"
Set rstData = gobjDataConn.Execute(strSQL)
If NOT rstData.BOF AND NOT rstData.EOF Then
lngRecordCnt = rstData("EXPR_RECORD_CNT")
Else
lngRecordCnt = 0
End If
' ---------------------------------------------------------------------
' Define query to get Top 10 Songs
' ---------------------------------------------------------------------
strSQL = "" _
& "SELECT EXPR_SONG_CNT , TSG_SONG_TITLE, TSG_ARTIST " _
& "FROM qryTopSongs " _
& "ORDER BY EXPR_SONG_CNT DESC"
' ---------------------------------------------------------------------
' Get data
' ---------------------------------------------------------------------
Set rstTopSongs = Server.CreateObject("ADODB.Recordset")
With rstTopSongs
Set .ActiveConnection = gobjDataConn
.Source = strSQL
.PageSize = 10
.CursorLocation = adUseClient
.Open
End With
' ---------------------------------------------------------------------
' Create table framework
' ---------------------------------------------------------------------
%>
| Pos. |
Voted |
Song |
Artist |
<%
' ---------------------------------------------------------------------
' Create table lines
' ---------------------------------------------------------------------
If NOT rstTopSongs.BOF and NOT rstTopSongs.EOF Then
For intLineNo = 1 TO 10
Response.Write ""
' Create line number cell
%>
|
<%=intLineNo%>
|
<%
' Output fields in record
For intCol = 0 to rstTopSongs.Fields.Count - 1
Set objField = rstTopSongs.Fields(intCol)
If strComp(objField.name, "EXPR_SONG_CNT", vbTextCompare) = 0 Then
If lngRecordCnt > 1 Then
strCellValue = Round((objField.value / lngRecordCnt) * 100, 1) & "%"
Else
strCellValue = objField.value
End If
Else
If IsNull(objField.value) Then
strCellValue = " "
Else
strCellValue = Server.HTMLEncode(objField.value)
End If
End If
' Output cell
%>
<%=strCellValue%>
|
<%
Next
Response.Write " "
rstTopSongs.MoveNext
If rstTopSongs.EOF then
Exit For
End If
Next
Response.Write " "
End If
' ---------------------------------------------------------------------
' Destroy local object references
' ---------------------------------------------------------------------
Set rstData.ActiveConnection = Nothing
Set rstData = Nothing
Set rstTopSongs.ActiveConnection = Nothing
Set rstTopSongs = Nothing
END SUB
' *************************************************************************
SUB DisplayMessage(istrMsg, ivarWidth)
' ---------------------------------------------------------------------
' DESCRIPTION OF ROUTINE
' ---------------------------------------------------------------------
' Purpose: To display a message in the HTML output.
' Assumptions: None
' Effects: None
' Inputs: None
' Returns: None
' ---------------------------------------------------------------------
%>
 |
<%=istrMsg%>
|
<%
END SUB
%>
|
All
ASP script ©2001 JWS
|
|
|
 |
|
|
Disclaimer:
While every attempt has been made to ensure the accuracy of information provided,
the authors of this site take no responsibility for the consequences of use of
this information
This website is offered for noncommercial, educational and entertainment purposes
only |
|