View Single Post
Old 09-14-2000, 04:23 AM   #7
mosquito
SQL nutcase
 
mosquito's Avatar
 
Join Date: Sep 2000
Location: Belgium
Posts: 1,136
Send a message via AIM to mosquito
Post

I didn't write ASP code, I only supplied the SQL Statements you could use to retrieve the data you wanted.
I assume that conn is the ADO connection object you are using, and rs is the recordset object, and SQLQuery is a string variable to hold the SQL Statement

Code:
sub WriteResult()
  dim conn
  dim rs
  dim SQLQuery
  
  Set conn = Server.CreateObject("ADODB.Connection")
  
  conn.ConnectionString = "Driver={SQL Server};Server=CARTMAN;UID=usr_intranet;PWD=intranet"
  conn.CursorLocation = 3
  conn.open
  
  SQLQuery = "select top 5 playername, sum(score) score "
  SQLQuery = SQLQuery & "from t_link l "
  SQLQuery = SQLQuery & "inner join t_player p "
  SQLQuery = SQLQuery & "on p.player_id = l.player_id "
  SQLQuery = SQLQuery & "group by playername"
  
  Set rs = conn.Execute(SQLQuery)
  response.write("<table>" & vbcrlf)
  response.write("  <tr valign=""top"" align=""center"">" & vbcrlf)
  response.write("    <td><b>Golf Results</b></td>" & vbcrlf)
  response.write("  </tr>" & vbcrlf)
  response.write("  <tr>" & vbcrlf)
  response.write("    <td>" & vbcrlf)
  response.write("      <table>" & vbcrlf)
  response.write("        <tr>" & vbcrlf)
  response.write("          <td> </td>" & vbcrlf)
  response.write("          <td><b> Player Name</b></td>" & vbcrlf)
  response.write("          <td><b> Score </b></td>" & vbcrlf)
  response.write("        </tr>" & vbcrlf)
  if not rs is nothing then
    Do While Not rs.EOF
        response.write("      <tr valign=""top"">" & vbcrlf)
        response.write("        <td>" & rs.index & "</td>" & vbcrlf)
        response.write("        <td> " & rs.fields("playername").value & "</td>" & vbcrlf)
        response.write("        <td>" & rs.fields("score").value & "</td>" & vbcrlf)
        response.write("      </tr>" & vbcrlf)
        rs.movenext
    loop
      rs.close
  end if
  response.write("      </table>" & vbcrlf)
  response.write("    </td>" & vbcrlf)
  response.write("  </tr>" & vbcrlf)
  response.write("</table>" & vbcrlf)
  
end sub
You can use this sub anywhere you want to create a table with the list of Golf Players.
I hope this makes things clear. If not, pop me a mail.

[Edited by mosquito on 09-14-2000 at 05:37 AM]
mosquito is offline   Reply With Quote