| HTML Tutorials |
|
|
| XML Tutorials |
|
|
| Browser Scripting |
|
|
| Server Scripting |
|
|
| .NET (dotnet) |
|
|
| Multimedia |
|
|
| Web Building |
|
|
| Java Tutorials |
|
|
| Programming Langauges |
|
|
| Soft Skills |
|
|
|
|
By Using the GetString() method to we speed up our ASP script instead of using multiple Response.Write's.
|
|
We can increase the speed of our ASP Script by using GetString() method in place of writting multiple Response.Write() method.
|
|
Here an example of multiple Response.Write() method used that show how to display a database query in an HTML table:.
|
|
<html>
<body>
<h2>Delete Record</h2>
<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open "c:/database/dataone.mdb"
cid=Request.Form("employeeID")
if Request.form("companyname")="" then
set rs=Server.CreateObject("ADODB.Recordset")
rs.open "SELECT * FROM employee WHERE employeeID='" & cid & "'",conn
%>
<form method="post" action="demo_delete.asp">
<table>
<%for each x in rs.Fields%>
<tr>
<td><%=x.name%></td>
<td><input name="<%=x.name%>" value="<%=x.value%>"></td>
<%next%>
</tr>
</table>
<br /><br />
<input type="submit" value="Delete record">
</form>
<%
else
sql="DELETE FROM employee"
sql=sql & " WHERE employeeID='" & cid & "'"
on error resume next
conn.Execute sql
if err<>0 then
response.write("No update permissions!")
else
response.write("Record " & cid & " was deleted!")
end if
end if
conn.close
%>
</body>
</html>
|
|
|
For a large query,we write Response.write() method no of time,this can slow down the script processing time, since many Response.Write commands must be processed by the server.
The solution is to have the entire string created, from <table> to </table>, and then output it - using Response.Write just once.
|
|
The GetString() method allows to display the string with writting only one Response.Write()method. It eliminates the do...loop code and the conditional test that checks if the recordset is at EOF.
|
|
str = rs.GetString(format,rows,coldel,rowdel,nullexpr)
|
|
|
To create an HTML table with data from a recordset, we only need to use three of the parameters given bellow.These three parametre are optional.
coldel - the HTML to use as a column-separator
rowdel - the HTML to use as a row-separator
nullexpr - the HTML to use if a column is NULL
|
|
<html>
<body>
<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open "c:/database/dataone.mdb"
set rs = Server.CreateObject("ADODB.recordset")
rs.Open "SELECT Companyname, Contactname FROM employee", conn
str=rs.GetString(,,"</td><td>","</td></tr><tr><td>"," ")
%>
<table border="1" width="100%">
<tr>
<td><%Response.Write(str)%></td>
</tr>
</table>
<%
rs.close
conn.close
set rs = Nothing
set conn = Nothing
%>
</body>
</html>
|
|
|
The str variable in above program contains a string of all the columns and rows returned by the SQL SELECT statement.Between each column the HTML </td><td> will appear, and between each row, the HTML </td></tr><tr><td> will appear. This will produce the exact HTML we need with only one Response.Write() method was used.
|
Share And Enjoy:These icons link to social bookmarking sites where readers can share and discover new web pages.
Keywords:ADO Speed Up, visual basic ado, ado stored procedure, ado ms access, ado asp net, ado insert into,
ado sql server, microsoft access ado, ado vb net, ado visual basic 6
|
|
| HTML Quizes |
|
|
| XML Quizes |
|
|
| Browser Scripting Quizes |
|
|
| Server Scripting Quizes |
|
|
| .NET (dotnet) Quizes |
|
|
| Multimedia Quizes |
|
|
| Web Building Quizes |
|
|
| Java Quizes |
|
|
| Programming Langauges Quizes |
|
|
| Soft Skills Quizes |
|
|
|