Click to See Complete Forum and Search --> : Disappeariing data
zingmatter
02-07-2007, 08:13 AM
This is driving me mad...
set rsR = c.execute(sql_command)
do while not rsR.eof
response.write "<!-- " & rsR("a") & " -->"
d = rsR("a")
response.write d
rsR.movenext
loop
The above code (abridged version of original), will write the value of rsR("a") into the page. But I can't get the variable d to take the value of rsR("a"). So the page appears blank but the source code shows the commented value of rsR("a").
Does this make any sense to anyone. I've come across this problem before but I just can't figure it out.
Thanks
russell
02-07-2007, 01:56 PM
i can't see how this is possible. is d declared? what are the values of rsR("a") ?
zingmatter
02-07-2007, 02:50 PM
rsR("a") is defined as ntext in a SQL Server db table. d has been declared, even initailised d = "". It just shouldn't happen. I can't happen... yet... aaaarrrggghhhh
russell
02-07-2007, 03:22 PM
there is something else going on. let's see the real code. i copied/pasted your code above and it worked fine for me.
zingmatter
02-07-2007, 04:08 PM
Ok then:
<%
Dim a
Dim aR
Dim q
Dim s
Dim qq
Dim rsS,rsC
Dim counter
Dim lastsess
lastsess = ""
counter = 0
sql = "SELECT distinct question from qrybeme_results order by question"
set rs = conn.execute(sql)
do while not rs.eof
'//build header on question names
h = h & rs("question") & ","
rs.movenext
loop
h = left(h,len(h) - 1)
hsp = split(h,",")
x = ubound(hsp) + 4
sql = "select count(sessionReferenceId) as c from beme_session_references"
set rsC = conn.execute(sql)
y = rsC("c")
'//load 1d arrays
redim q(x)
q(0) = "sessionid"
q(1) = "username"
q(2) = "refid"
q(3) = "completed"
for n = 4 to x
q(n) = hsp(n-4)
next
redim s(y)
sql = "select sessionid from beme_session_references,beme_references where " & _
"beme_session_references.referenceid = beme_references.referenceid order by beme_references.reference"
set rsS = conn.execute(sql)
do while not rsS.eof
s(counter) = rsS("sessionid")
counter = counter + 1
rsS.movenext
loop
'//now load data into 2d array
redim aR(x,y)
counter = -1
sql = "select * from qrybeme_results"
set rsR = conn.execute(sql)
Dim answer
answer = ""
do while not rsR.eof
response.write "<!-- " & len(rsR("a")) & " -->"
sess = rsR("sessionid")
answer = rsR("a")
response.write "<!-- " & answer & " -->"
if lastsess <> cstr(rsR("sessionid")) then
counter = counter + 1
response.write counter & " csess: " & rsR("sessionid") & " lastsess: " & lastsess & "<br>"
aR(0,counter) = rsR("sessionid")
aR(1,counter) = rsR("username")
aR(2,counter) = rsR("reference")
aR(3,counter) = rsR("completed")
end if
thisqi = getQi(rsR("question"))
aR(thisqi,counter) = answer
response.write ">" & aR(thisqi,counter) & sess & "<"
lastsess = cstr(rsR("sessionid"))
rsR.movenext
loop
function getQi(question)
Dim localc
localc = 0
for each t in q
if cstr(question) = cstr(t) then
getQi = localc
end if
localc = localc + 1
next
end function
A few tables going on here, the aim to load data into a 2d array so I can drop it into a csv file for someone to analyse.
russell
02-07-2007, 04:29 PM
this
response.write "<!-- " & answer & " -->"
prints out nothing inside the comment tags?
why not use the ADO GetRows method instead of manually building the array. or if u want to output to CSV how 'bout rs.GetString ?
are these other values populating correctly?
aR(0,counter) = rsR("sessionid")
aR(1,counter) = rsR("username")
aR(2,counter) = rsR("reference")
aR(3,counter) = rsR("completed")
zingmatter
02-07-2007, 06:25 PM
The bit in the comment did print out, but the variable didn't get assigned.
rs.GetString - looked it up and could well be useful (ADO is definitely one of weak points so will look further).