jon24422531
Technical User
Hi everyone
This is not pretty, but I am trying to modify some borrowed code for our internal company website. (80% of the code is "borrowed")
I can understand most of the workings, but I am not sure how to get it step through my recordset. I have tried several methods including getRows, but I am just going round in circles.
So that's the connection. Now I want to draw a graph (with the "borrowed" code)
The error is "Object doesn't support this property or method: 'fieldItem'"
Could some please explain how I can get the code to step through the rsData recordset
Coding is like the works of Shakespeare, I can read it and appreciate it, but I could never write it.
Thanks
Jonathan
This is not pretty, but I am trying to modify some borrowed code for our internal company website. (80% of the code is "borrowed")
I can understand most of the workings, but I am not sure how to get it step through my recordset. I have tried several methods including getRows, but I am just going round in circles.
Code:
Dim MyConn
Dim rsData
Dim strSQL
set MyConn = Server.CreateObject("ADODB.Connection")
MyConn.Open "Driver={SQL Server}; Server=FTLive;Database=WorkLog;Uid=app;Pwd=;"
Set rsData = Server.CreateObject("ADODB.Recordset")
strSQL = "select distinct sortedby as Name, count(*) as cnt from .........."
rsData.Open strSQL, MyConn
Code:
lTotal = 0
for i=1 to 5
' Check if the value exists
if rsData.fieldItem("value" & i)<>""then
if cLng(rsData("value" & i))>0 then
lTotal= cLng(rsData("value" & i)) + lTotal
end if
end if
next
str="<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=2>"
str=str & "<TR bgcolor=lightgrey><TH align=left>Label</TH>"
str=str & "<TH WIDTH=5> </TH><TH>Value</TH>"
str=str & "<TH WIDTH=10> </TH><TH align=center>"
str= tr & "%</TH></TR>"
for i=1 to 5
lValue = rsData("value" & i)
' If value exists, process it
if rsData("value" & i) <> "" then
lValue = cLng(lValue)
' Calculate percentage of total
iPercent = Round((lValue/lTotal) * 100)
str = str & " <TR><TD>" & rsData("name" & i)
str = str & "</TD><TD> </TD><TD align=center>"
str = str & lValue & "</TD><TD> </TD>"
str = str & "<TD valign=middle><TABLE><TR><TD bgcolor="
' Set bar color
if iPercent>50 then
str = str & "darkgreen"
else
str = str & "darkred"
end if
str = str & "><IMG SRC='/images/s.gif' width=" & ((iPercent/100)*barSize) & " height=5>"
str = str & "</TD><TD><FONT SIZE=1>" & iPercent
str = str & "%</FONT></TD></TR></TABLE></TD></TR>"
end if
next
str = str & "</TABLE>"
response.write(str)
%>
Put a line here...
<%
rsData.Close
set rsData = Nothing
set MyConn = Nothing
Could some please explain how I can get the code to step through the rsData recordset
Coding is like the works of Shakespeare, I can read it and appreciate it, but I could never write it.
Thanks
Jonathan