I've had a good look through the old posts and i cant find anything which helps me with this (probably newbie) probelm... any advise or links of use would be appreciated.
I have a recordset, and used it to dim an array, but i'm struggling to get the array to display as the recordset does (like when you look at it in sql). Array's aren't my favourite atm
Code:
If request("subbut")="Search" then
sSql="myStoredProc '"&session("selclient")&"', "&session("srch")
set rsmTmp=Server.CreateObject("ADODB.Recordset")
rsmTmp.Open sSql, connSub()
If not rsmTmp.EOF then
Set oFso=Server.CreateObject("Scripting.FileSystemObject")
[i use this fso later]
arrResult = rsmTmp.getrows()
If isarray(arrResult) then
response.write "<table>"
response.write "<tr>"
for x = 0 to Ubound(arrResult)
for y = 0 to Ubound(arrResult,2)
response.write "<td>"
response.write arrResult(x,y)
response.write "</td>"
next
response.write "</tr>"
next
End If
Else
response.write "<p>No Results</p>"
End If
End If
This does display all the data, but the axis' are the wrong way round, E.g.
row1 cell1, row2 cell1, row3 cell1 etc.
row1 cell2, row2 cell2, row3 cell2 etc.
If not rsmTmp.EOF then
Set oFso=Server.CreateObject("Scripting.FileSystemObject")
'Set oFile = oFso.OpenTextFile(Server.MapPath("Excel Files\"&sFname), 2, True)
arrResult = rsmTmp.getrows()
If isarray(arrResult) then
response.write "<table>"
response.write "<tr>"
for x = 0 to Ubound(arrResult)
response.write "<td>"
response.write arrResult(x,Ubound(arrResult,2))
response.write "</td>"
next
response.write "</tr>"
End If
response.write "</table>"
Else
response.write "<p>No Results</p>"
End If
If not rsmTmp.EOF then
Set oFso=Server.CreateObject("Scripting.FileSystemObject")
'Set oFile = oFso.OpenTextFile(Server.MapPath("Excel Files\"&sFname), 2, True)
arrResult = rsmTmp.getrows()
If isarray(arrResult) then
response.write "<table>"
for x = 0 to Ubound(arrResult,2)
response.write "<tr>"
for y = 0 to Ubound(arrResult,1)
response.write "<td>"
response.write arrResult(y,x)
response.write "</td>"
next
response.write "</tr>"
next
End If
response.write "</table>"
Else
response.write "<p>No Results</p>"
End If
I was only referencing the last record in the response above. And the original code was looking at the wrong axis' in sql. I'd taken it as golden from another online tutorial that that ubound(myArray,2) will always look at columns
Bookmarks