|
Database Display via
GetString by Charles Carroll
This page demonstrates the capabilities how to
display a table from a SQL statement a very fast and scaleable way using a
recordset method called GetString. GetString essentially asks the
backend database to build a huge string instead of moving the data as rows and
columns. It allows very limited specifications, basically what string to place
between each column and row and how to display nulls. Notice the total absence
of the traditional EOF loop.
Its speed and scalability advantages
are explained in:
Http://www.learnasp.com/advice/whygetrows.asp
This example does require ADO 2.0 or
greater which can be downloaded from:
http://www.microsoft.com/data
If you are unsure which ADO version
your server has
http://www.learnasp.com/freebook/asp/versioncheck.aspx
will help you determine this.
Does this approach matter for small data sets for example
9 rows x 2 columns of data? YES!!!!!!!!
My site has SQLserver scripts that run like lightning. I
once needed to fill a 9 item listbox from Access and got 90 sec script timeouts
with movenext. Getstring never timed out. So in a real production situation it
makes weak databases feasible and of course reduces the load on more industrial
back-ends so maybe the SQLserver doesn't need as many indexes or RAM upgrades.
"The Worlds Fastest Listbox"
http://www.learnasp.com/freebook/asp/speedappdata.aspx
shows the only faster way to display databases.
filename=/learn/test/dbtablegetstring.asp
<TITLE>dbtablegetstring.asp</TITLE>
<body bgcolor="#FFFFFF">
<%
whichDSN="DSN=Student;uid=student;pwd=magic"
mySQL="select * from publishers where state='NY'"
set conntemp=server.createobject("adodb.connection")
conntemp.open whichDSN
set rstemp=conntemp.execute(mySQL)
If rstemp.eof then
response.write "No records matched<br>"
response.write mySQL & "<br>So cannot make table..."
Call CloseAll
response.end
end if
response.write "<table border='1'><tr>"
'Put Headings On The Table of Field Names
for each whatever in rstemp.fields
response.write "<td><b>" & whatever.name & "</B></TD>"
next
response.write "</tr><tr><td>"
response.write rstemp.getstring(,, "</td><td>", "</td></tr><TR><TD>", "-null-")
response.write "</td></tr></table>"
Call CloseAll
SUB CloseALL
rstemp.close
set rstemp=nothing
conntemp.close
set conntemp=nothing
END SUB
%>
</body></html>
|