Recommended: Basic Development Entry Level: Comparison between JSP and ASP Since Microsoft launched ASP (ActiveServerPage), it has been loved by WEB developers for its powerful functions and simplicity and easy to learn. However, it has common problems with Microsoft products and can only be used on Windows platforms, although it can be used in LINUX by adding controls
Asynchronous execution refers to retrieving data in the background, and the data you have obtained can be used on the web page before all the data is returned. Although all data may be needed, asynchronous work can start processing data at least in advance. It can also allow users to see certain content first, which makes the Web site look more responsive.Similar to TDC, RDS data controls can set their properties by setting parameters of OBJECT tags or writing code. Here is an example:
<OBJECT CLASSID=clsid:BD96C556-65A3-11D0-983A-00C04FC29E33
ID=dsoAuthors WIDTH=0 HEIGHT=0>
<PARAM NAME=Connect VALUE=DSN=pubs>
<PARAM NAME=Server VALUE=W2000>
<PARAM NAME=SQL VALUE=SELECT * FROM Authors>
</OBJECT>
Equivalent to:
<OBJECT CLASSID=clsid:BD96C556-65A3-11D0-983A-00C04FC29E33
ID=dsoAuthors WIDTH=0 HEIGHT=0>
</OBJECT>
<SCRIPT LANGUAGE=JScript>
function window.onload()
{
dsoAuthors.Connect = DSN=pubs;
dsoAuthors.Server = W2000;
dsoAuthors.SQL = SELECT * FROM Authors;
dsoAuthors.Refresh();
}
</SCRIPT>
A DSN is used here for the Connect parameter, as this is perfect for the page, but can also be any valid ADO connection string.
URL is a new feature provided by ADO version 2.5, allowing the use of a file as a data source. The file can be in two formats: one is a record set saved using the Recordset.Save method; the other is an ASP page that creates a record set and saves it in a stream. The code is as follows:
<OBJECT CLASSID=clsid:BD96C556-65A3-11D0-983A-00C04FC29E33
ID=dsoAuthors WIDTH=0 HEIGHT=0>
<PARAM NAME=URL VALUE=DataPage.asp>
</OBJECT>
The file DataPage.asp contains the following VBScript code:
<%
Dim rsData
Set rsData = Server.CreateObject(ADODB.Recordset)
rsData.Open SELECT * FROM Authors, strConn
rsData.Save Response, adPersistXML
rsData.Close
Set rsData = Nothing
%>
This just creates a record set and then saves the record set in XML format into the Response object using the Save method. In earlier versions of ADO, recordsets could only be saved as physical files, while ADO version 2.5 could be saved as streams directly. The result of this ASP page is the XML format record set. The next chapter will look at all topics about streaming and XML data.
Using URL attributes is better than using Connect and SQL attributes. The biggest advantage is that there will be no connection details in the web pages that users can see. Consider the following object definition:
<OBJECT CLASSID=clsid: BD96C556-65A3-11D0-983A-00C04FC29E33
ID=dsoAuthors WIDTH=0 HIGHT=0>
<PARAM NAME=Connect VALUE=DSN=pubs>
<PARAM NAME=Server VALUE=W2000>
<PARAM NAME=SQL VALUE=SELECT * FROM Authors>
</OBJECT>
The first line shows the details of the connection. At this time, we can see that DSN is pubs, and we have selected all columns of the authors table. This undoubtedly provides a potential path for computer hackers to enter the Web site, because they know the name of the server and some details of the database. Now, consider using URL properties:
<OBJECT CLASSID=clsid: BD96C556-65A3-11D0-983A-00C04FC29E33
ID=dsoAuthors WIDTH=0 HIGHT=0>
<PARAM NAME=URL VALUE=DataPage.asp>
</OBJECT>
Now, what the user sees is the URL address of an ASP web page, without any detailed information about the server and database.
Using the CONNECT/SQL attribute method, users can clearly see the details of the connection, while using the URL is data. From this point of view, an issue of security has been eliminated.
When setting properties of RDS data controls in scripts, you must use the Refesh method as follows:
<SCRIPT LANGUAGE=JScript>
function window.onload()
{
dsoAuthors.URL=DataPage.asp;
dosAuthors.Refresh();
}
</SCRIPT>
This forces the data control to use the new property value and re-retrieve the data from the data provider. In addition to the Refresh method, there are many other methods for RDS data control, as shown in Table 10-3:
Table 10-3 Methods and descriptions of RDS data controls
method
illustrate
Cancel
Cancel any asynchronous operation
CancelUpdate
Cancel any modification to the data
CreateRecordset
Create an empty record set, which allows new data sets to be created locally
MoveFirst
Move to the first record
MoveLast
Move to the last record
MoveNext
Move to the next record
MovePrevious
Move to previous record
Refresh
Update data from data storage
Reset
Apply filtering or sorting criteria
SubmitChanges
Return all unresolved modifications to the data store
Later in this chapter, you will see the use of most methods.
3. MSHTML Data Control
What makes Microsoft HTML (MSHTML) data control special is that MSHTML is an integral part of IE and can provide a data source based on HTML documents. Although MSHTML is not essentially a format used for data storage, MSHTML may become more useful if there are indeed many HTML web pages containing certain data formats.
Share: Detailed explanation of ASP common mathematical functions Abs Atn Cos, etc. [Name] Abs [Category] Mathematical Function [Prototype] Abs(number) [Parameter] Required. Number parameter is any valid numeric expression [return value] of the same type as number [exception/error] None [scan