Techniques for making Dynamic Web pages

Source: Internet
Author: User
Tags add format copy odbc sql query access database access
Web| News | tips | page with the development of Internet applications, the home page is no longer just an enterprise information window, many of the company's business can be achieved through the Internet, such as customers can order through the supplier's home page, the company can collect customer feedback through their own home page, and so on. On the other hand, as the company's business development, geographical distribution widened, between the head office and the subsidiaries to establish a simple LAN is not possible, at this time can be achieved through the Internet to achieve the business between the subsidiary and the head office, that is, the adoption of the current more popular enterprise application solutions that NCA structure 0 Client solutions to achieve this. Therefore, how to make your home page and the database dynamically connected, how to operate the home page to manipulate the records in the database has become a very important topic. Here are a few ways to solve the dynamic connection between the home page and the database.

First, you need to prepare for Windows 95 or Windows NT as follows to make it possible for everyone to take a look at the next side of the instructions.

1. Create an Access database, C:\My Documents\mydata.mdb.

2. The table MyTable (a dblong,b dbtext,c dblong) is built in the MyData database and the appropriate amount of experimental data is added.

3. Establish the System DSN (database Source name), set in ODBC in Control Panel, take the data source named Accessmdb, and point to the newly built MyData database.

4. Install PWS (Personal Web Server), which is located in the \ADDONS\PWS directory of the Windows 98 CD.

5. Use FrontPage to create a new web on PWS, such as http://yourhostname/myweb, by default, Yourhostname is your host name.

6. Open the new myweb with the FrontPage software, create a new subdirectory scripts, and then set scripts as an executable subdirectory.

At this point, if your settings are correct, then you can open Internet Explorer (IE), and after you type http://yourhostname/myweb/scripts in the Address bar, you will see the following prompts:

Directory Listing Denied

This Virtual Directory does not allow contents to is listed

This is because the directory does not have an HTML file for the province (typically Default.htm), but it does not allow you to list the directories, but this indicates that your PWS settings are correct. The first method of making is described below.

A Complete Setup with the FrontPage Database Region Wizard Wizard

• Open FrontPage, enter the already built web, MyWeb, create a new page newpage1, and edit it.

• Click "Insert" in the menu bar and select "Database", "Database Region Wizard", and a dialog box pops up.

• In the input field under ODBC Data source name, enter the built DSN, Accessmdb, and then click the Next button to go to the next step.

• Enter the Select A,b,c from mytable in the input field under "Enter" SQL string for the query, and then click the Next button to enter the step.

• Click on the Add button to enter field name a in the input fields under "Enter the name of" a query field to is added to the list, and then click the OK button.

• Repeat the previous step to add both fields B and C to the query list.

• Click the Finish button.

• You are prompted to save the page in an executable directory and change the extension to *.asp, newpage1.htm to the scripts directory as prompted, and rename Newpage1.htm to newpage1.asp.

Enter http://youhostname/myweb/scripts/newpage1.aspin the IE Address bar, press Enter and you will see the experimental data in the database are displayed.

This method is simple to operate, but not flexible, the resulting HTML file readability is poor, not easy to add two times link.

Two Direct call to HTTPODBC.DLL (IDC/HTX)

Httpodbc. The DLL, called Internet Database Connector, is an ISAPI (Internet Server application programming Interface) that accesses the database by calling ODBC.

This approach involves three main documents:

1. Httpodbc.dll

After PWS is installed, the file is placed in the \windows\system\inetsrv directory.

2. IDC file

IDC file is a text file with an extension of IDC (Internet databse Connector), which contains the necessary information for the HTML file to connect to the database, SQL statements, template file names, and so on.

File format: Name:value, where name is the project name, such as DataSource, template, SQLStatement, username, password, and so on.

Project Description:

DataSource: Data source name, that is, the data source name (System DSN) that is built in ODBC in Control Panel.

Template: The template file name, which is located in an executable subdirectory with the IDC file.

SQLStatement: The SQL statement to execute.

An IDC file should contain at least datasource, template, SQLStatement three items.

3. HTX file

It is an HTML file with an extension of HTX (HTML Extension file), which is the format description of the records returned to the page in the database.

Format Description:

<%begindetail%>: The starting position when multiple records are returned.

<%endetail%>: The end position when multiple records are returned.

<%FIELDNAME%>: The returned field name represents the method.

4. Example

. Use Notepad to create a new file with the following contents:

Datasource:accessmdb

Template:myhtx.htx

Sqlstatement:select A,b,c from MyTable

Save the file in the scripts directory with the MYIDC.IDC name.

. Use Notepad to create a new file with the following contents:

<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">

<title>home page</title>

<body>

<table border= "1" width= "100%" >

<tr>

<th width= "30%" align= "center" >A</th>

<th width= "30%" align= "center" >B</th>

<th width= "40%" align= "center" >C</th>

</tr>

<%begindetail%>

<tr>

<TD width= "30%" ><small><small><%a%></small></small></td>

<TD width= "30%" ><small><small><%b%></small></small></td>

<TD width= "40%" ><small><small><%c%></small></small></td>

</tr>

<%enddetail%>

</table>

</body>

Save the file in the MYHTX.HTX name and save the file to the scripts directory. Enter HTTP://YOURHOSTNAME/MYWEB/SCRIPTS/MYIDC.IDCin the address bar of IE, and press ENTER to see the returned records.

This method looks troublesome, but it is extremely convenient to use. In fact, you can query in the database and copy the correctly generated SQL statements into the SQLStatement project of the IDC file. On the other hand, you can use a page editor (such as FrontPage) to make a format page, and then copy the resulting HTML file into the HTX file, and then press the HTX file format to change to a standard HTX file.

In addition, IDC files and HTX files are more readable, you can modify the HTX file, resulting in two links, that is, according to the returned records linked to different IDC or HTML files, such as:

<tr><a href= "<%a%>.htm" ><%a%></A></tr>

Thus, in the returned table, a two-time link is formed and can be linked to a different a.htm file, depending on the value of a returned field a.

Three Make a Dynamic Web page with an ActiveX component

The point of this approach is to first create an ActiveX part on the Web server with Visual BASIC 5.0 or Visual C + +, and then call OLEISAPI.DLL to achieve access to the database. The advantage is that it is very flexible to add totals (total or subtotal) to the output HTML file, and the fields can be output in the format you specify.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.