Author |
Topic |
gcool12
Starting Member
22 Posts |
Posted - 2007-12-11 : 17:00:23
|
My sql Query is<%Dim connection, sql, rsSet connection = Server.CreateObject ("ADODB.Connection")connection.open "DSN=5s"sql= "TRANSFORM Sum([5s_Audit].Average) AS SumOfAverage "sql = sql & "SELECT Department FROM 5s_Audit GROUP BY Department PIVOT DatePart('ww',[Due_Date]);" 'Response.write sql 'Response.endset rs = server.createObject("ADODB.RecordSet")rs.Open sql, connection%>The way I create the table is:<TABLE cellSpacing=1 cellPadding=1 border=1 align=Center class canResize="true" bgcolor="White" id="mainTable"> <%Do while not rs.EOF%> <tr align=center onmouseover='highlightRow(this, "#FFFBCB")' onmouseout='highlightRow(this)'> <td bgcolor="steelblue" class='normal' nowrap align="center"> <b><FONT Face = "arial" COLOR="white"><%=rs(i) %></Font></b></td> <%rs.MoveNext Loop%>The i needs to lop through as many times as there is columns. I tried putting a counter in the sql but it just did the first column.It needs to look somethign like:<td bgcolor="steelblue" class='normal' nowrap align="center"> <b><FONT Face = "arial" COLOR="white"><%=rs(0) %></Font></b></td><td bgcolor="steelblue" class='normal' nowrap align="center"> <b><FONT Face = "arial" COLOR="white"><%=rs(1) %></Font></b></td><td bgcolor="steelblue" class='normal' nowrap align="center"> <b><FONT Face = "arial" COLOR="white"><%=rs(ETC. Until End) %></Font></b></td>Any Ideas? |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-12-11 : 17:04:07
|
Dim iLoop AS Bytefor iloop = 1 to rs.fields.countresponse.write "<td bgcolor="steelblue" class='normal' nowrap align="center"> <b><FONT Face = "arial" COLOR="white"><%=rs(" & iloop & ") %></Font></b></td>"next E 12°55'05.25"N 56°04'39.16" |
 |
|
gcool12
Starting Member
22 Posts |
Posted - 2007-12-11 : 17:27:59
|
When I try to enter that in sql it makes the whole page sql code, what am I doing wrong?Thanks,Sry, ive never used asp, or sql lol so this is tough |
 |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-12-11 : 17:44:39
|
My mistake.FOR iLoop = 0 to rs.Fields.Count - 1NEXTSince Fields collection is zero based. E 12°55'05.25"N 56°04'39.16" |
 |
|
gcool12
Starting Member
22 Posts |
Posted - 2007-12-11 : 17:46:50
|
response.write "<td bgcolor="steelblue" class='normal' nowrap align="center"> <b><FONT Face = "arial" COLOR="white"><%=rs(" & iloop & ") %></Font></b></td>" Its this line thats turning everything to server code for soem reason. This goes in the sql code correct? |
 |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-12-11 : 17:53:42
|
[code]<TABLE cellSpacing=1 cellPadding=1 border=1 align=Center class canResize="true" bgcolor="White" id="mainTable"><%Dim iLoop AS Bytedo until rs.bof or rs.eof reponse.write "<tr align=center onmouseover='highlightRow(this, "#FFFBCB")' onmouseout='highlightRow(this)'>" for iloop = 0 to rs.fields.count - 1 response.write "<td bgcolor="steelblue" class='normal' nowrap align="center"> <b><FONT Face = "arial" COLOR="white">" & rs(iloop).Value & "</Font></b></td>" next reponse.write "</tr>" rs.movenextloop%></TABLE>[/code] E 12°55'05.25"N 56°04'39.16" |
 |
|
gcool12
Starting Member
22 Posts |
Posted - 2007-12-11 : 17:56:51
|
eh somethign is still makign everythign below that code servercode, almost like if the closing %> isnt there |
 |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-12-11 : 18:05:15
|
Try again! E 12°55'05.25"N 56°04'39.16" |
 |
|
gcool12
Starting Member
22 Posts |
Posted - 2007-12-11 : 18:12:50
|
I removed option explicit now i get Error Type:Microsoft VBScript compilation (0x800A0401)Expected end of statement |
 |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-12-11 : 18:22:16
|
[code]<TABLE cellSpacing=1 cellPadding=1 border=1 align=Center class canResize="true" bgcolor="White" id="mainTable"><%Dim iLoop AS Bytedo until rs.bof or rs.eof reponse.write "<tr align=center onmouseover='highlightRow(this, ""#FFFBCB"")' onmouseout='highlightRow(this)'>" for iloop = 0 to rs.fields.count - 1 response.write "<td bgcolor='steelblue' class='normal' nowrap align='center'> <b><FONT Face='arial' COLOR='white'>" & rs(iloop).Value & "</Font></b></td>" next reponse.write "</tr>" rs.movenextloop%></TABLE>[/code] E 12°55'05.25"N 56°04'39.16" |
 |
|
gcool12
Starting Member
22 Posts |
Posted - 2007-12-11 : 18:42:04
|
Thanks i got it working by removing as Byte, now it displays the departments on the left with all their averages for each week on the right, is their any way to get the column headings to print above them, ie: departments, 49, 50, 51 (the weeks) |
 |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-12-11 : 18:50:32
|
[code]<TABLE cellSpacing=1 cellPadding=1 border=1 align=Center class canResize="true" bgcolor="White" id="mainTable"><%Dim iLoop As Integer, iFields As Integer'Show all headersreponse.write "<tr>"Set iFields = rs.fields.count - 1for iloop = 0 to iFields response.write "<td>" & rs.Fields.(iLoop).Name & "</td>"nextreponse.write "</tr>"'Iterate all recordsdo until rs.bof or rs.eof reponse.write "<tr align=center onmouseover='highlightRow(this, ""#FFFBCB"")' onmouseout='highlightRow(this)'>" for iloop = 0 to iFields response.write "<td bgcolor='steelblue' class='normal' nowrap align='center'> <b><FONT Face='arial' COLOR='white'>" & rs(iLoop).Value & "</Font></b></td>" next reponse.write "</tr>" rs.movenextloop%></TABLE>[/code] E 12°55'05.25"N 56°04'39.16" |
 |
|
gcool12
Starting Member
22 Posts |
Posted - 2007-12-11 : 19:05:06
|
<%Dim iloop, iFields 'Show all headersResponse.Write("</tr>") Set iFields = rs.fields.count -1for iloop = 0 to iFields Response.Write("<td>"& rs.Fields.(iloop).Name &"</td>")next'Iterate all recordsdo until rs.bof or rs.eofResponse.Write("<tr align=center onmouseover='highlightRow(this, ""#FFFBCB"")' onmouseout='highlightRow(this)'>")Response.Write "<td bgcolor='SteelBlue' class='normal' nowrap align='center'> <b><FONT Face='arial' COLOR='White'>" & rs(0).Value & "</Font></b></td>" for iloop = 1 to iFields response.write "<td bgcolor='White' width='30' class='normal' nowrap align='center'> <b><FONT Face='arial' COLOR='Black'>" & rs(iloop).Value & "</Font></b></td>" next Response.Write("</tr>") rs.movenextloop%>at thsi line:Response.Write("<td>"& rs.Fields.(iloop).Name &"</td>")it says Expected identifierif I comment it out then it has this error:Object required: '[number: 5]'at this line:Set iFields = rs.fields.count -1 |
 |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-12-11 : 19:11:02
|
Can you please show some effort yourself?<TABLE cellSpacing=1 cellPadding=1 border=1 align=Center class canResize="true" bgcolor="White" id="mainTable"><%Dim iLoop, iFieldsreponse.write "<tr>"iFields = rs.Fields.Count - 1for iloop = 0 to iFields response.write "<td>" & rs.Fields.(iLoop).Name & "</td>"nextreponse.write "</tr>"do until rs.bof or rs.eof reponse.write "<tr align=center onmouseover='highlightRow(this, ""#FFFBCB"")' onmouseout='highlightRow(this)'>" for iloop = 0 to iFields response.write "<td bgcolor='steelblue' class='normal' nowrap align='center'><b><FONT Face='arial' COLOR='white'>" & rs(iLoop).Value & "</Font></b></td>" next reponse.write "</tr>" rs.movenextloop%></TABLE> E 12°55'05.25"N 56°04'39.16" |
 |
|
gcool12
Starting Member
22 Posts |
Posted - 2007-12-11 : 19:14:23
|
Sorry I really appreciate all of your help! Ive just been messing with this for so long im about to pull my hair out. It sux being told to do somethign you knwo nothing about. |
 |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-12-11 : 19:16:29
|
Just say no! It is a sign of integrity. E 12°55'05.25"N 56°04'39.16" |
 |
|
gcool12
Starting Member
22 Posts |
Posted - 2007-12-11 : 19:19:22
|
ive gotten it all doen but this last part :) |
 |
|
gcool12
Starting Member
22 Posts |
Posted - 2007-12-11 : 19:22:20
|
UGH response.write "<td>" & rs.Fields.(iLoop).Name & "</td>" expected identifierWhats that mean! |
 |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-12-11 : 19:23:14
|
rs.Fields(iLoop).Name Drop the point between Fields and paranthesis.<TABLE cellSpacing=1 cellPadding=1 border=1 align=Center class canResize="true" bgcolor="White" id="mainTable"><%Dim iLoop, iFieldsreponse.write "<tr>"iFields = rs.Fields.Count - 1for iloop = 0 to iFields response.write "<td>" & rs.Fields(iLoop).Name & "</td>"nextreponse.write "</tr>"do until rs.bof or rs.eof reponse.write "<tr align=center onmouseover='highlightRow(this, ""#FFFBCB"")' onmouseout='highlightRow(this)'>" for iloop = 0 to iFields response.write "<td bgcolor='steelblue' class='normal' nowrap align='center'><b><FONT Face='arial' COLOR='white'>" & rs(iLoop).Value & "</Font></b></td>" next reponse.write "</tr>" rs.movenextloop%></TABLE> E 12°55'05.25"N 56°04'39.16" |
 |
|
gcool12
Starting Member
22 Posts |
Posted - 2007-12-12 : 09:30:16
|
Right now the page shows the date 48, 49, 51, 52, but when it gets to jan. 08 it puts week 1 08 before week 48 of 07 instead of after week 52, is there any way to change this in the query? |
 |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-12-12 : 09:41:49
|
sql = sql & "SELECT Department FROM 5s_Audit GROUP BY Department PIVOT FORMAT([Due_Date], ""yyyyww"", 2, 2);" E 12°55'05.25"N 56°04'39.16" |
 |
|
Next Page
|