Database Access Data Warehouse access) Parts

Source: Internet
Author: User
Tags how to use sql

Lesson 5: Use Database Access
(Data Warehouse access) Parts

The ASP database access group uses ActiveX Data Objects (ADO) to provide a simple and easy-to-use method, information stored in the data warehouse or in the data warehouse with access questions (such as the sub-Table grid, it can only follow the Open Database Connectivity (ODBC) standards. In this lesson, you will connect to a Microsoft? Access the user data base and display the table of contents. You will learn how to use SQL select statements to query data and create an HTML table to display the result.

----------

Identification data database

Before using a data warehouse through a database access group? Control panel? In the od bc process, identify the data database. In this example, you will use a Microsoft? Access the data base.

Open it on the computer of the Web server (localhost? Control panel ?.

Double click? ODBC? Icon, then click? System DSN? Select a card. DSN will inform the data warehouse about the position of the Data Warehouse file in the dynamic process sequence (used to configure the data warehouse and communicate with the database. You can create three types of DSN: User DSN, which can only be used by you; system DSN ), it can be used by all users of the computing machine. The DSN (F Ile DSN) file saves the DSN information as a file, and allow all users to use the same data base to drive the process sequence. The DSN used in this tutorial must be a system DSN ). Single click? Tian Jia ?, Select? Microsoft Access drive sequence ?, Then click? ?.

In? Data Source Name? In the box, press asptutorial, and then click? Select ?. Select the btcustm R. MDB File (which is in the WINNT \ HELP \ IIS \ HTM \ tutorial directory under tacit conditions), and then click? Are you sure you want ?.

Single click? Are you sure you want? Close the dialog box.

Create a group instance

Open the database. asp file in the tutorial directory (C: \ winnt \ HELP \ IIS \ HTM \ tutorial) on the localhost web server with the text editor.

Search for text? Define scripting language ?, Insert the following script into the text row:

<%@ Language = "VBScript" %> 〉

This mark is the first line of all. asp files.

Search for text? Tutorial lesson-ADO connection ?, The script is inserted after the text row.

You must create an object instance before using it. Please re-create and paste it to the next order:

<%

Set objconnection = server. Createobject ("ADODB. Connection ")

If, before this, another user has completed the teaching process, then these scripts have already been completed? Tutorial lesson? The line is removed. Use a reset script to overwrite existing scripts, or replace unused databases. ASP copies the template sub-object (C: \ winnt \ HELP \ IIS \ HTM \ tu torial/template) to the tutorial directory.

For database access components, you must specify the ODBC Data Source (the data base from which data is to be retrieved ), the method is to open a connection to the data base. Reset and paste it to the next order:

Objconnection. Open "asptutorial"

Use the execute method of the Database Access Group to send a structured query statement (Structured Query Language, SQL) to the data database) and save the returned records to rscustomerslist. Copy the following script and paste it to the objconnection. open clause:

Sqlquery = "select * from MERs"

Set rscustomerslist = objconnection. Execute (sqlquery)

%> 〉

If you pass the SQL query string directly to the execute method, instead of assigning a value to the variable sqlquery, You can merge the two rows. When the SQL select row ratio is long, to make the script easier to read, you can assign the character string value to a variable (such as sqlquery ), then pass the variable name to the execute method.

Show return result set combination

You can combine the result set as a table lattice. The structure of this table lattice is determined by the fields in the SQL select clause. Shows the rows returned by the check, just like the rows following the loop in the result set combination. In this example, the returned data is displayed in the HTML table row.

In the database. asp file, search for text? Tutorial lesson-display ADO data ?, Copy and paste the script to the end of the row:

<% Do until rscustomerslist. EOF %> 〉

<Tr> 〉

<TD bgcolor = "f7efde" align = center> 〉

<%= Rscustomerslist ("contactfirstname") %> 〉

<%= Rscustomerslist ("contactlastname") %> 〉

</TD> 〉

<TD bgcolor = "f7efde" align = center> 〉

<A href = "mailto: <% = rscustomerslist (" contactlastname ") %>"> 〉"〉

<%= Rscustomerslist ("contactlastname") %> </a> 〉

</TD> 〉

<TD bgcolor = "f7efde" align = center> 〉

<%= Rscustomerslist ("city") %> 〉

</TD> 〉

<TD bgcolor = "f7efde" align = center> 〉

<%= Rscustomerslist ("stateorprovince") %> 〉

</TD> 〉

</Tr> 〉

If, before this, another user has completed the teaching process, then these scripts have been saved. Overwrite an existing script with a composite script, or replace unused Bayshore. asp from the template object to the tutorial object.

When a piece is? Really? Vbscriptdo... loop statement re-executes a sentence. The sentence that is re-executed can be a script command or an HTML document and a mark. In this case, you can draw a table row in HTML and insert the returned data in the script for each repeat.

To complete the cycle, use the movenext method to move the row to the next row. Because this sentence is still in the do... loop sentence, it is re-restored directly until the end of the text is reached. Re-compile the script and paste it? Tutorial lesson-retrieve next row? After:

<%

Rscustomerslist. movenext

Loop

%> 〉

Save the database. asp file in plain text format, and return the file editor. Note: Post-fix of text files. asp does not need to be replaced by the text editor.

To verify whether the ASP page you created is normal, export your browser to http: // localho ST/IISHelp/IIS/help/htm/tutorial/database. ASP. (If you want to return back to this tutorial, you only need to click it in the browser? Last page? Or? Back? You can press the button. ) Self-learning participation

If you are using Windows NT, you can access the entire database access group example by visiting the registration air demonstration section. Click behind the scenes image to create more knowledge about the script of this web node. On the Bayshore travel web page, there is also a link to the notice air to show the sample node.

Note: If you have not asked about the notice air demonstration node, the link above will take you to the E xploration air main page. If you want to return to this tutorial, you only need to click it in the browser? Last page? Or? Back? You can press the button.

Now, you have used ActiveX components and asked us to study Module 3: compile your own components.

----------

Module 3: Compile the component

Select the script language of this course.

In Module 2, you have learned about the group provided by ASP, and the group you created is full

We have special requirements.

You need to create an ASP program to provide specific financial functions through the Web node. ASP

No direct connection is provided for this purpose. No, you can create a Java or ActiveX group.

Solve the problem. You will learn this in this module.

If you want to learn how to create and use group items, first select the table cells in the lower area:

----------

Select the group type to be created in this lesson:

Visual Basic 5.0 ActiveX Components

Visual J ++ 1.1 Java? Parts

----------

Click

To save and check the result of your work in this module, You need:

Are there/IISHelp/IIS/htm/tutorial virtual projects on the localhost web server? Write )? And? Edit the Web server (script Web Server )? Permission. For more information, see configure the Web server permission.

Your Windows NT account number must be recorded in driveletter: \ winnt \ system32 \ inetsrv \ and its sub-files with Windows NT File System (NTFs) (the driveletter in this section represents the appropriate driver number of the localhost web server, if you have not installed the package to the default category, use your installation category to replace \ winnt \ System32 ).

To complete this module, you must install it on the localhost Web Server:

Microsoft? Visual Basic 5.0 Professional Edition 32-bit edition or Visual Basic 5.0 Enterprise Edition development system.

If you have disabled the web browser to run Java program functions, enable this function before starting the tutorial.

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.