Question : Display data from MSAccess to table

I am using
- MSAccess
- Microsoft SQL Server  2000 - 8.00.760 (Intel X86)
- FrontPage 2002

I am trying to display data from an MSAccess DB. I want the asp page to pull data from the table for the header. There will never be more than 15 headers in the 1st row. For the first column, I want to specify the row labels. I have it working to display the data when I specify the column headers, but not the opposite.

Currently my code displays as:

                  Space           PERC
Boston           2000           9021  
Cleveland       2300           4500  
Los Angeles    1900           4500  
New York       1800           2100  


I want the display to be:

               Boston       Cleveland      Los Angeles     New York
Space        2000          2300              1900                 1800
PERC          9021          4500              4500                 2100

Code attached.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
<%
'Create recordset
 Dim sql, objRS

 sql = "SELECT tblGeneral.ChartID, tblGeneral.City, tblGeneral.State, " & _
 	"tblSpace.SpaceAll, tblSpace.SpacePERC " & _
	"FROM tblGeneral INNER JOIN tblSpace ON tblGeneral.ChartID= tblSpace.ChartID " & _
	"WHERE tblGeneral.VISNID LIKE '12' "
	
		If Request.querystring("sort") = "" then
 			sql = sql & "ORDER BY City"
 		Else
  			sql = sql & "ORDER BY " & Request.querystring("sort")
  		End If			
	
	Set objRS = Server.CreateObject("ADODB.Recordset")
	objRS.Open sql, objConn


'First, display the TABLE header info:
Response.Write "<TABLE class='CCTable' cellspacing='0' border='1' cellpadding='5' width='350px'>"

'Display table headings for each column in the Recordset

Response.Write "<TR style='background-color:white;'>"
Response.Write "<TH scope='col' width='150px'>&nbsp;</font></th>"
Response.Write "<TH scope='col' width='50px'><b>Space</b></font></th>"
Response.Write "<TH scope='col' width='50px'><b>PERC</b></font></th>"

While Not objRS.EOF

	Response.Write "<TR><TD scope='row' width='150px'>" & objRS("City") & "&nbsp;</TD>" & VbCrLf
	Response.Write "<TD scope='row' width='50px'>" & objRS("SpaceAll") & "&nbsp;</TD>" & VbCrLf
	Response.Write "<TD scope='row' width='50px'>" & objRS("SpacePERC") & "&nbsp;</TD></TR>" & VbCrLf

   'Advance the recordset
   objRS.MoveNext

Wend
objRS.Close
Set objRS = Nothing

Response.Write "</TABLE></div>" & vbCrLf

%>

Answer : Display data from MSAccess to table

Give this a try
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
<%
'Create recordset
 Dim sql, objRS

 sql = "SELECT tblGeneral.ChartID, tblGeneral.City, tblGeneral.State, " & _
 	"tblSpace.SpaceAll, tblSpace.SpacePERC " & _
	"FROM tblGeneral INNER JOIN tblSpace ON tblGeneral.ChartID= tblSpace.ChartID " & _
	"WHERE tblGeneral.VISNID LIKE '12' "
	
		If Request.querystring("sort") = "" then
 			sql = sql & "ORDER BY City"
 		Else
  			sql = sql & "ORDER BY " & Request.querystring("sort")
  		End If			
	
	Set objRS = Server.CreateObject("ADODB.Recordset")
	objRS.Open sql, objConn


'First, display the TABLE header info:
Response.Write "<TABLE class='CCTable' cellspacing='0' border='1' cellpadding='5' width='350px'>"

'Display table headings for each column in the Recordset

Dim rowHeader, rowAll, rowPerc

rowHeader = "<TR style='background-color:white;'><td>&nbsp;</td>"
rowAll = "<TR style='background-color:white;'><td><b>Space</b></td>"
rowPerc = "<TR style='background-color:white;'><td><b>PERC</b></td>"

While Not objRS.EOF

	rowHeader = rowHeader & "<th scope='col'>" & objRS("City") & "&nbsp;</th>" & VbCrLf
	rowAll = rowAll & "<TD scope='row'>" & objRS("SpaceAll") & "&nbsp;</TD>" & VbCrLf
	rowPerc = rowPerc & "<TD scope='row'>" & objRS("SpacePERC") & "&nbsp;</TD>" & VbCrLf

   'Advance the recordset
   objRS.MoveNext

Wend
objRS.Close
Set objRS = Nothing

rowHeader = rowHeader & "</tr>" & VbCrLf
rowAll = rowAll & "</tr>" & VbCrLf
rowPerc = rowPerc & "</tr>" & VbCrLf

Response.Write rowHeader
Response.Write rowAll
Response.Write rowPerc

Response.Write "</TABLE></div>" & vbCrLf

%>
Random Solutions  
 
programming4us programming4us