Disconnected Recordsets and GetRows method
Which is better and preferred?
Example:
<%
dim rstRecords, mySql, blnRecordsFound, fld
mySql = "SELECT FIELD1, FIELD2, FIELD3 FROM TESTTABLE;"
Rem -Disconnected Recordset Method
set rstRecords = server.createobject("adodb.recordset")
rstRecords.cursorlocation=aduseclient
rstRecords.open mySQL, my_Conn
Rem -disconnect the recordset
set rstRecords.activeconnection = nothing
if rstRecords.EOF then
blnRecordsFound = false
else
blnRecordsFound = true
end if
if blnRecordsFound then
do until rstRecords.EOF
Response.write rstRecords("Field1") & "<BR />"
Response.write rstRecords("Field2") & "<BR />"
Response.write rstRecords("Field3") & "<BR /><BR />"
rstRecords.MoveNext
loop
end if
rstRecords.Close
Set rstRecords = nothing
Rem -GetRows method
dim arrRecords, iLoop
set rstRecords = server.createobject("adodb.recordset")
rstRecords.cursorlocation=aduseclient
rstRecords.open mySQL, my_Conn
Rem -disconnect the recordset
set rstRecords.activeconnection = nothing
if rstRecords.EOF then
blnRecordsFound = false
else
blnRecordsFound = true
arrRecords = rstRecords.getRows()
end if
rstRecords.Close
Set rstRecords = nothing
if blnRecordsFound then
const field1 = 0
const field2 = 1
const field3 = 2
for iLoop = 0 to ubound(arrRecords, 2)
Response.write arrRecords(field1, iLoop) & "<BR />"
Response.write arrRecords(field2, iLoop) & "<BR />"
Response.write arrRecords(field3, iLoop) & "<BR />"
next
end if
%>
Opinions Please:
1. How these two methods compare in terms of performance?
2. Advantages/Disadvantages of one method over the other