![]() ![]() | ||
As mentioned in the In Depth section of this chapter, you can waste a lot of time waiting for server round trips to handle your data. The Microsoft Internet Explorer has some built-in data source objects that can hold recordsets (note—here, I'm discussing ADO recordsets, not ADO.NET datasets) that you can access in scripting languages like JavaScript, which means you can work with records from a database directly in the browser. For a complete discussion on this topic, including examples, see the Coriolis HTML Black Book.
Here's an example using the XML data source object (DSO) in the Internet Explorer; this example is named ie.html in the IE folder on the CD-ROM. You can use the XML DSO to read in data in XML format and create an ADO recordset. For example, here's the authors table from the pubs database in XML format, in a file named dataset.xml (this file was created in the example in "Writing Datasets to XML and Reading Datasets from XML" in Chapter 22):
<?xml version="1.0" standalone="yes"?>
<DataSet1 xmlns="http://www.tempuri.org/DataSet1.xsd">
<authors>
<au_id>172-32-1176</au_id>
<au_lname>White</au_lname>
<au_fname>Johnson</au_fname>
<phone>408 496-7223</phone>
<address>10932 Bigge Rd.</address>
<city>Menlo Park</city>
<state>CA</state>
<zip>94025</zip>
<contract>true</contract>
</authors>
<authors>
<au_id>213-46-8915</au_id>
<au_lname>Green</au_lname>
<au_fname>Marjorie</au_fname>
<phone>415 986-7020</phone>
⋮
Now I can read in dataset.xml and navigate through the data in it using navigation buttons in JavaScript like this in ie.html (the com.ms.xml.dso.XMLDSO.class applet used here comes built into Internet Explorer):
<HTML> <HEAD> <TITLE> Using the XML Data Source Control </TITLE> </HEAD> <BODY> <CENTER> <H1> Using the XML Data Source Control </H1> <APPLET CODE="com.ms.xml.dso.XMLDSO.class" ID="dsoAuthors" WIDTH=0 HEIGHT=0 MAYSCRIPT=true> <PARAM NAME="URL" VALUE="dataset.xml"> </APPLET> First Name: <INPUT TYPE="TEXT" DATASRC="#dsoAuthors" DATAFLD="au_fname" SIZE=10><P> Last Name: <INPUT TYPE="TEXT" DATASRC="#dsoAuthors" DATAFLD="au_lname" SIZE=10><P> ID: <INPUT TYPE="TEXT" DATASRC="#dsoAuthors" DATAFLD="au_id" SIZE=12><P> <BUTTON ONCLICK="dsoAuthors.recordset.MoveFirst()" > << </BUTTON> <BUTTON ONCLICK="if (!dsoAuthors.recordset.BOF) dsoAuthors.recordset.MovePrevious()" > < </BUTTON> <BUTTON ONCLICK="if (!dsoAuthors.recordset.EOF) dsoAuthors.recordset.MoveNext()" > > </BUTTON> <BUTTON ONCLICK="dsoAuthors.recordset.MoveLast()"> >> </BUTTON> </CENTER> </BODY> </HTML>
You can see the results in Figure 23.15; this technique offers a simple way of viewing data and navigating through it in the Internet Explorer without any server round trips.
Tip |
For other ways of binding data in the Internet Explorer, including the Remote Data Service (RDS), which can connect directly to databases on servers using connection strings and SQL, see the Coriolis HTML Black Book. |
Related solution: |
Found on page: |
---|---|
966 |
![]() ![]() | ||