W
webb
I have a table with a huge amount of data.
At present my data is like so.
userid:1588 | 1 | CR1
userid:1588 | 2 | CR2
userid:1588 | 1 | CR3
userid:1588 | 1 | CR4
userid:1588 | 1 | CR5
userid:1588 | 2 | CR6
Intened format below:
userid | CR1| CR2| CR3| CR4| CR5| CR6 "Columns"
1588| 1| 2| 1| 1| 1| 2 "Data"
I already figured out how to get the data out with some great help.
But it works for one record.
I have 4342 records how can i loop the routine below to get all id's fro me.
I tried the following but i'm missing something.
dim ID, fArray
str ="SELECT userid FROM RESULTED GROUP BY userid"
Set rsx = cn80.Execute(str)
Do while not rsx.EOF
ID = rsx("userid")
fArray = fArray & ID &","
rsx.movenext
Loop
members = fArray
selections = Split(members, ",")
for j = 0 To UBound(selections)
'run the normail routine here which is below
next
<%
dim userid, numbers, cid, sArray
str="SELECT userid, critic_result, criticId from RESULTED WHERE userid='" &
selections(j)& "'"
Set rs = cn80.Execute(str)
Do while not rs.EOF
numbers = rs("critic_result")
cid = rs("criticId")
userid = rs("userid")
sArray = sArray & "cr"&cid &"="& numbers &","
rs.movenext
Loop
'Response.write sArray
' open recordset
str_sql2 = "INSERT INTO SurveyResultsExported (userid, "
Dim strNames,strValues2
tempArr = Split(sArray,",")
for i = 0 to (UBound(tempArr)-1)
Values = split(tempArr(i),"=")
'CREATE FIELD NAME LIST
strNames = strNames & Values(0) & ","
'CREATE VALUE LIST
strValues2 = strValues2 & "'" & Values(1) & "', "
next
'BUILD SQL STRING then go for it
str_sql2 = str_sql2 & left(strNames, (Len(strNames)-1)) & ")
VALUES ("&pracid&", " & left(strValues2, (Len(strValues2)-1)) & ")"
'cn80.execute(str_sql2)
response.write(str_sql2)
response.end
cn80.Close
Set cn80 = Nothing
%>
Thank you for you help.
webb
At present my data is like so.
userid:1588 | 1 | CR1
userid:1588 | 2 | CR2
userid:1588 | 1 | CR3
userid:1588 | 1 | CR4
userid:1588 | 1 | CR5
userid:1588 | 2 | CR6
Intened format below:
userid | CR1| CR2| CR3| CR4| CR5| CR6 "Columns"
1588| 1| 2| 1| 1| 1| 2 "Data"
I already figured out how to get the data out with some great help.
But it works for one record.
I have 4342 records how can i loop the routine below to get all id's fro me.
I tried the following but i'm missing something.
dim ID, fArray
str ="SELECT userid FROM RESULTED GROUP BY userid"
Set rsx = cn80.Execute(str)
Do while not rsx.EOF
ID = rsx("userid")
fArray = fArray & ID &","
rsx.movenext
Loop
members = fArray
selections = Split(members, ",")
for j = 0 To UBound(selections)
'run the normail routine here which is below
next
<%
dim userid, numbers, cid, sArray
str="SELECT userid, critic_result, criticId from RESULTED WHERE userid='" &
selections(j)& "'"
Set rs = cn80.Execute(str)
Do while not rs.EOF
numbers = rs("critic_result")
cid = rs("criticId")
userid = rs("userid")
sArray = sArray & "cr"&cid &"="& numbers &","
rs.movenext
Loop
'Response.write sArray
' open recordset
str_sql2 = "INSERT INTO SurveyResultsExported (userid, "
Dim strNames,strValues2
tempArr = Split(sArray,",")
for i = 0 to (UBound(tempArr)-1)
Values = split(tempArr(i),"=")
'CREATE FIELD NAME LIST
strNames = strNames & Values(0) & ","
'CREATE VALUE LIST
strValues2 = strValues2 & "'" & Values(1) & "', "
next
'BUILD SQL STRING then go for it
str_sql2 = str_sql2 & left(strNames, (Len(strNames)-1)) & ")
VALUES ("&pracid&", " & left(strValues2, (Len(strValues2)-1)) & ")"
'cn80.execute(str_sql2)
response.write(str_sql2)
response.end
cn80.Close
Set cn80 = Nothing
%>
Thank you for you help.
webb