Exporting Data to Web Servers

Access 2003 has the capability to export data from tables and queries in the following Web-enabled formats:

  • HTML Documents (*.html; *.htm) for static display of data in pages delivered from any Web server. Exporting as HTML is the simplest process.

  • Microsoft Active Server Pages (*.asp) for dynamic display of data in browser-independent Web pages delivered from Internet Information Server (IIS) 3+. You must specify an OLE DB or ODBC data source and other parameters to export data to an .asp file.

  • Microsoft IIS 1-2 (*.htx: *.idc) for dynamic display of data in a format determined by a Filename.htx template file. The Filename.idc file defines an Internet data connection and an SQL query to generate the data for the page. You must specify an ODBC data source and other parameters to export data to a .htx/.idc file pair. This option is available only for Access data projects (ADP) with SQL Server databases; Access version 2000 and earlier supported this option for Jet databases. This format is obsolete and isn't secure.

  • graphics/new.gif SharePoint Team Services() to export a table to a list on a Windows SharePoint Services (WSS) server. Chapter 26, "Integrating with InfoPath and SharePoint Services," explains how to take advantage of Access 2003's new WSS list export and linking features.

  • graphics/new.gif XML Documents (*.xml) for use with applications that can parse and transform XML to HTML or text. As mentioned near the beginning of this chapter, Chapter 23 covers the use of Access 2003's new XML import/export features for intranet- and Internet-based database applications.

Only brief descriptions for the use of the first two formats of the preceding list is provided here, because saving tables or queries as data access pages (DAP) is a much more effective method of delivering dynamic data to browsers.

Saving an .htm File to a Web Server

If a standard HTML table is adequate for presentation of your data, exporting a table as an HTML file is the simplest process. Access writes the HTML code for you, but you can use Notepad or any other HTML editor to modify the page design.

To export a table (Customers for this example) to an HTML table and display it in Internet Explorer (IE) 5.0+, do this:

  1. graphics/table_wizard.gif Select the table in the Database window, and choose File, Export to open the Export Table 'Customers' To dialog.

  2. In the Save As Type list, select HTML Documents (*.html;*.htm) which adds Customers as the default filename. Be sure to check the Save Formatted check box next to the Export button.

  3. Navigate to the folder that stores your Web pages. The default folder for IIS is \Inetpub\wwwroot. If you don't have a Default.htm page in the folder, you can make the table the default page for the server or a subfolder by naming the file Default.htm. Click Export to open the HTML Output Options dialog.

  4. Accept the default entries in the HTML Output dialog. An HTML template isn't required, and default HTML encoding works with all PC browsers. Click OK to create the .htm file.

  5. graphics/internet_explorer.gif Launch IE and type servername[/filename.html] in the Address bar. If the Web server is running on your computer, you can use localhost[/filename.html] as the URL. The /Filename.html element of the address is required if you didn't specify Default.htm as the filename. IE adds the http:// prefix for you and opens the table (see Figure 8.61). In this example, the server is the local computer and the file is Default.htm.

    Figure 8.61. The HTML table Access exports won't win Web-design awards, but it's better than the HTML default format that appears if you forget to mark the Save Formatted check box.

    graphics/08fig61.jpg

Pages generated by exporting data from a table or query contain static data. To keep a page's data current, you must periodically re-export the table or query.

Note

You also can import data from standard HTML tables saved as an .htm file to an Access table. In the Files of Type list of the Import dialog, choose HTML Documents (*.html;*.htm).


Exporting Tables to Active Server Pages

Active Server Pages overcome the need for periodic refreshing of static .htm pages by generating dynamic pages. Dynamic pages read the table data or execute a query to return the specified data each time a user opens a page. Access 2003's ASP export feature for tables and queries requires an ODBC data source for the database before you export the table. If you don't have a System or File DSN for the database, you must create one.

Tip

Use ASP, not HTML, to make data from tables and queries available to intranet or Internet users in a basic tabular format. ASP requires more server resources than HTML pages when many users open the page simultaneously, but the advantage of providing current data outweighs the server load issue.


To create an ODBC data source and export Northwind.mdb's Suppliers table to ASP, do the following:

  1. graphics/odbc.gif From Control Panel, launch the ODBC Administrator tool from the Administrative Tools subfolder of Control Panel in Windows XP/2000.

  2. Click the System DSN tab to create a data source that's available regardless of who's logged on to the Web server, and click the Add button (the New button in Windows 2000) to open the Create New Data Source dialog.

  3. Select the Microsoft Access Driver (*.mdb) in the Name list, and click Finish to open the ODBC Microsoft Access Setup dialog.

  4. Type a short name, NwindJet for this example, in the Data Source Name text box and an optional description of the data source in the Description text box.

  5. Click Select to open the Select Database dialog, navigate to Northwind.mdb in the ...\Office11\Samples folder, and double-click the file in the Database Name list to close the dialog. The ODBC Microsoft Access Setup dialog appears as shown in Figure 8.62. Northwind.mdb isn't secured, so you don't need to specify a system database (workgroup file).

    Figure 8.62. Create a new ODBC System DSN for the database that contains the table or query to generate the page's data.

    graphics/08fig62.jpg

  6. Click OK twice to close the two dialogs.

  7. graphics/table_wizard.gif Select the table to export, Suppliers for this example, in the Database window, and choose File, Export to open the Export Table 'Suppliers' To dialog.

  8. Select Microsoft Active Server Pages (*.asp) in the Save As Type list, accept or change the default filename (Suppliers), and click Export to open the Microsoft Active Server Pages Export Options dialog.

  9. Skip the HTML Template text box, and type the name of the ODBC DSN you specified in step 4 in the Data Source Name text box. The database isn't secured, so you can skip the User to Connect As and Password for User text boxes.

  10. Type http:// followed by the name of your Web server, localhost for this example, in the Server URL text box. Type a nominal value, such as 5 (minutes), in the Session Timeout (Min) text box (see Figure 8.63). Click OK to export Filename.asp to the ...wwwroot folder of the specified server.

    Figure 8.63. Exporting a simple ASP from a table of an unsecured database requires specifying only the ODBC DSN, the URL of the server, and a session timeout value.

    graphics/08fig63.gif

  11. graphics/internet_explorer.gif Close Access, launch IE, and type http://servername/filename.asp in the Address text box. Press Enter to display the table (see Figure 8.64). If you don't close Access before opening the ASP page, you receive an HTTP 500.100 ASP "file in use" error.

    Figure 8.64. Tables or queries exported to ASP have the same table format as those Access exports as static HTML pages.

    graphics/08fig64.jpg

Note

None of the hyperlinks in the Homepage field that refer to pages "(on the World Wide Web)" work, because ODBC or the generated ASP script doesn't translate the hyperlink field for Web pages to the required <a href:... ></a> format.


graphics/active_data_objects.gif Exported ASP contain standard VBScript code to open a connection to the specified database with the OLE DB data provider for ODBC. An SQL statement, SELECT * FROM [tablename], opens an Active Data Objects (ADO) Recordset of the table, and a loop structure populates the table rows with the contents of the Recordset. To view the ASP code, navigate to the server's ...\wwwroot folder and open the .asp file you exported in Notepad. Figure 8.65 shows most of the VBScript code for the Suppliers.asp page.

Figure 8.65. Access uses a component from Microsoft FrontPage to generate the VBScript code to establish the connection to the database and generate the Recordset to populate the table rows.

graphics/08fig65.jpg

For more information on exporting Access tables in XML format, see "Exporting Tables and Queries to XML and HTML," p. 954.




Special Edition Using Microsoft Office Access 2003
Special Edition Using Microsoft Office Access 2003
ISBN: 0789729520
EAN: 2147483647
Year: 2005
Pages: 417

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net