Forum Moderators: open
im having a bit of trouble with the getrows thing. im told it is the way to do things, and it seems nice but..
i was shown this way initially.
Set oConn = Server.CreateObject("ADODB.Connection")
oConn.Open("dsn=xx")
q="SELECT * FROM tablename"
set oRS=Server.CreateObject("ADODB.recordset")
oRS.open q,oConn
While not oRS.EOF
response.write oRS(1) & oRS("fieldname") ... blah
oRS.MoveNext
Wend
oRS.close
oConn.close
but with getrows like this?
...
q="SELECT * FROM tablename"
set oRS=Server.CreateObject("ADODB.recordset")
oRS.open q,oConn
if not oRS.EOF or oRS.BOF then
arrRows = oRS.getRows()
for x = 1 to?
im stuck
next
else
...
end if is the getrows way loads faster?
sorry if this is silly question.
You would loop through it like:
For x=0 to UBound(arrRows,2)
'Display First Column
response.write(arrRows(0,x))
'Display second column
response.write(arrRows(1,x))
Next
You can also do a loop within the loop to just spit out all the column too. Get faliliar with working with 2-D arrays and it is easy. Also, after you use the GetRows you can just check to see if it contains any data by using IsArray(arrRows) in stead of the RS.EOF. So, as soon as you use get rows you can just close your connection and destroy the RS objects...You don't even really need the RS object you can use the connection.execute(strSQL) i believe..lots of good articles out there.