Published: Thursday, June 22, 2000
Using Sql Server 7 Web Assistant to Improve performance of Asp Pages, Part 2
By Venkatraman Ambethkar
Read Part 1
In Part 1 we looked at running the SQL Server 7
Web Assistant Wizard to create an HTML file with the database information, output.html.
In this part we'll examine how to display this HTML file in the combo box on our ASP page!
Step3: Including the generated html in our ASP files wherever necessary
Start by opening your HTML editor and creating a new ASP page. We want to
use a server-side include to import the contents of output.html. Therefore,
add <!-include file="output.html"--> to the file.
Now save this file as Display.asp in your virtual directory. The code for this
sample file could be as follows.
<HTML>
<BODY>
<form>
<!-- #include file="output.html"-->
</form>
</BODY>
</HTML>
|
(To learn more about server-side includes be sure to read: The
Low-Down on #include.)
Now, request the Display.asp from your browser, you should get the drop down box!
You can insert, update or delete a row in the jobs table and refresh the browser,
you will get the drop down duly updated. Neat, eh?
As you can see, the coding that we have done is only for the Template.tpl,
which can also be used
for several other jobs which produce drop down boxes from other tables.
The rest of the work is only selecting things in the wizard. Even for creating the stored procedure
(sp_makewebtask) which does all the work, we can use the wizard and use the code generated by the wizard.
Comparison of Performance Test
In order to give you a clear picture of the advantages of using HTML files over
asp pages with database connection, I wrote another asp file which does exactly the same
but using ADO Recordset whose code is as given below,
<%
dim oConn,rs
set oConn=server.createobject("adodb.connection")
oConn.open "DRIVER={SQL Server};SERVER=Nana;" & _
"UID=sa;PWD=;DATABASE=pubs"
set rs=oConn.execute("select job_id,job_desc from jobs")
if not rs.eof then
response.write("<form><select name='cboJobs'>")
do while not rs.eof
response.write("<option value="& rs(0) &">"& rs(1))
rs.movenext
loop
response.write("</select></form>")
end if
rs.close
set rs=nothing
oconn.close
set conn=nothing
%>
|
and carried out tests using Microsoft-Web Application stress Tool on both these files.
Here is the tally.
|
Test Criteria | With include file | With Database Connection |
|
Threads = Stress Level *
Stress Multiplier |
100 = 10*10 | 100 = 10*10 |
|
Duration Of Test | 1 min | 1 min |
| Number of Hits | 12,981 | 2,382 |
| Requests Per Second | 216.01 | 39.65 |
| TTFB
(Total Time for First Byte)
in sec | 0.451 secs | 2.252 secs |
| TTLB
(Total Time for Last Byte)
in secs | 0.455.79 secs | 2.455 secs |
From the TTFB values, you can see how faster the file with include is.
Happy Programming.
Venkatraman Ambethkar