JavaScript Editor JavaScript Editor     JavaScript Debugger

Previous Section Next Section

Main Page

Using XML-Format Databases Directly in the Internet Explorer

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="">
    <phone>408 496-7223</phone>
    <address>10932 Bigge Rd.</address>
    <city>Menlo Park</city>
  <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 applet used here comes built into Internet Explorer):

            Using the XML Data Source Control

                Using the XML Data Source Control

            <APPLET CODE=""
                ID="dsoAuthors" WIDTH=0 HEIGHT=0 MAYSCRIPT=true>
               <PARAM NAME="URL" VALUE="dataset.xml">
            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 ONCLICK="if (!dsoAuthors.recordset.BOF)
                dsoAuthors.recordset.MovePrevious()" >
            <BUTTON ONCLICK="if (!dsoAuthors.recordset.EOF)
                dsoAuthors.recordset.MoveNext()" >
            <BUTTON ONCLICK="dsoAuthors.recordset.MoveLast()">



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.

Click To expand
Figure 23.15: Using the XML Data Source Control in the Internet Explorer.

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:

Writing Datasets to XML and Reading Datasets from XML


Previous Section Next Section

JavaScript Editor Free JavaScript Editor     JavaScript Editor